Skip to main content
added 223 characters in body
Source Link
Joseph R.
  • 40.5k
  • 8
  • 113
  • 146

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces, thereby invoking mkdir with a long list of arguments containing all your directory names at once instead of one at a time.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

One more thing, I would add quotes just in case the file names in your text file have spaces in them or other "special" characters:

xargs -I, mkdir "," <list.txt

or

xargs -I, mkdir "prefix_," <list.txt

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

One more thing, I would add quotes just in case the file names in your text file have spaces in them or other "special" characters:

xargs -I, mkdir "," <list.txt

or

xargs -I, mkdir "prefix_," <list.txt

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces, thereby invoking mkdir with a long list of arguments containing all your directory names at once instead of one at a time.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

One more thing, I would add quotes just in case the file names in your text file have spaces in them or other "special" characters:

xargs -I, mkdir "," <list.txt

or

xargs -I, mkdir "prefix_," <list.txt
added 223 characters in body
Source Link
Joseph R.
  • 40.5k
  • 8
  • 113
  • 146

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

One more thing, I would add quotes just in case the file names in your text file have spaces in them or other "special" characters:

xargs -I, mkdir "," <list.txt

or

xargs -I, mkdir "prefix_," <list.txt

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.

One more thing, I would add quotes just in case the file names in your text file have spaces in them or other "special" characters:

xargs -I, mkdir "," <list.txt

or

xargs -I, mkdir "prefix_," <list.txt
Source Link
Joseph R.
  • 40.5k
  • 8
  • 113
  • 146

This worked for me:

xargs mkdir <list.txt

This works because if you give multiple arguments to mkdir it will happily create all the directories it can create. xargs simply "flattens" your text file by replacing newlines with spaces.

If you want to add a fixed prefix (or suffix, or both):

xargs -I, mkdir prefix_, <list.txt

Whatever you put after the -I switch (a comma in this case) is replaced by the name that is read from the file.