How to create a folder and file within via single command

saurav9430

New Member
Joined
Nov 19, 2020
Messages
2
Reaction score
0
Credits
20
Hello All,
I am a newbie and learning Linux commands and came here to look for some help w.r.t a concern, but not sure how to find and where to find (in forum if something similar has already been posted).
Btw, my concern is:
How can we create a folder and file within folder via single command.
I know the easiest way to write both commands to create folder and file separated by comma in a single line but i am looking if there is any other/better way.
Regards,
Saurav Kumar
 
Last edited:


Hello All,
I am a newbie and learning Linux commands and came here to look for some help w.r.t a concern, but not sure how to find and where to find (in forum if something similar has already been posted).
Btw, my concern is:
How can we create a folder and file within folder via single command.
I know the easiest way to write both commands to create folder and file separated by comma in a single line but i am looking if there is any other/better way.
Regards,
Saurav Kumar

There is no way to do this... this is by design.
How would the command know whether you wanted a file or a directory?

You can do something like...

mkdir -p /my/long/path/to/a/folder

But mkdir assumes you want all directories.

You could then do something like

touch /my/long/path/to/a/folder/withthisfile.txt

But any command that creates directories creates directories only.
Any command that creates files, creates files only.

Technically everything in Linux is a file, even directories are really just files
with pointers to other files. There has to be a delimiter, a way for Linux to know
which is which.
 
got it and thanks for replying :)

for my other concern: how to make use of these forums available in this website. like how to search within a particular forum. any tips/guidlines
 
I use:

$search_terms site:example.com

As most forums have pretty basic search functionality.
 

Members online


Top