Jump to content

Linux folder creation

Go to solution Solved by Sauron,
40 minutes ago, lior1111 said:

if its even possible?

It's not possible using just mkdir but you can use a simple bash one liner:

 

for ((i=1; i <= 5 ; i++)); do echo "./path/to/folder_$i" | xargs -L 1 mkdir -p ; done

obviously replacing 1 and 5 with the range you want ;) 

Hello . linux noob here! , currently studying linux within a cyber course im attending to and i have an assignment im having a hard time figuring out with just google in hands. i wanted to know if theres a way to create a folder and subfolders within that folder in just one command. i managed to do something like that - Mkdir support ; mkdir support/support{1..3}
but i was wondering , as this is pretty much two codes in one line , if theres a way to do the same with a single command.

Thanks upfront! :)

Link to comment
https://linustechtips.com/topic/1215850-linux-folder-creation/
Share on other sites

Link to post
Share on other sites

6 minutes ago, Sauron said:

mkdir -p /path/to/folder

 

https://linux.die.net/man/1/mkdir

 

In general you can access manual pages on linux with


man <command>

 

thanks :) i know about man , im quite familiar with linux aleardy , but this is quite tricky because while i did know about mkdir -p , how do you make several folders in the main folders like that? i tried the following:

mkdir -p /path/to/{folder1..folder3}

but it just made a subfolder named {folder1..folder3}

i want something that can , in one command , have the same effect as the following:

mkdir support ; mkdir support/support{1..3}

essentially , creating 3 subfolders within that folder that im creating in this one command

if its even possible?
and also to not have like {x,x,x} , but having an option to create even 100 subfolders respectively , like {support1...support100}

 

Link to comment
https://linustechtips.com/topic/1215850-linux-folder-creation/#findComment-13769177
Share on other sites

Link to post
Share on other sites

40 minutes ago, lior1111 said:

if its even possible?

It's not possible using just mkdir but you can use a simple bash one liner:

 

for ((i=1; i <= 5 ; i++)); do echo "./path/to/folder_$i" | xargs -L 1 mkdir -p ; done

obviously replacing 1 and 5 with the range you want ;) 

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
https://linustechtips.com/topic/1215850-linux-folder-creation/#findComment-13769314
Share on other sites

Link to post
Share on other sites

1 minute ago, Sauron said:

It's not possible using just mkdir but you can use a simple bash one liner:

 


for ((i=1; i <= 5 ; i++)); do echo "./path/to/folder_$i" | xargs -L 1 mkdir -p ; done

obviously replacing 1 and 5 with the range you want ;) 

thanks alot man :) i got my answer

Link to comment
https://linustechtips.com/topic/1215850-linux-folder-creation/#findComment-13769321
Share on other sites

Link to post
Share on other sites

Or just 

mkdir -p support/support1 support/support2 support/support3

if it's not too much to write.

The Eight Fallacies of Distributed Computing

Essentially everyone, when they first build a distributed application, makes the following eight assumptions. All prove to be false in the long run and all cause big trouble and painful learning experiences.

  1. The network is reliable
  2. Latency is zero
  3. Bandwidth is infinite
  4. The network is secure
  5. Topology doesn’t change
  6. There is one administrator
  7. Transport cost is zero
  8. The network is homogeneous

        — Peter Deutsch

Link to comment
https://linustechtips.com/topic/1215850-linux-folder-creation/#findComment-13770338
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×