How to create a long list of directories with mkdir?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create a long list of directories with mkdir?
# 1  
Old 11-21-2017
How to create a long list of directories with mkdir?

Hi...

Thanks to read this...

I want to use mkdir to create many directories listed in a text file, let's say.

How do I do this?

Sorry for this maybe very basic question Smilie
# 2  
Old 11-21-2017
Quote:
Originally Posted by setub
Hi...

Thanks to read this...

I want to use mkdir to create many directories listed in a text file, let's say.

How do I do this?

Sorry for this maybe very basic question Smilie
care to share a sample content of the "text file"?
# 3  
Old 11-21-2017
Yes Smilie
Not a big list, here, but just for you to understand...

Code:
ms_ww_546
ms_rrL_99999
ms_nnn_67_756675


Last edited by Scott; 11-21-2017 at 12:22 PM.. Reason: Put file contents inline and removed attachment, it's not necessary for such a short list
# 4  
Old 11-21-2017
Okay, so for just three entries or many more, a simple loop should suffice.

Question: Are the underscores part of the name, or are they markers for the next directory, i.e. do you want 1_2_3 as you have in the file or 1/2/3?

What have you tried to use as a loop so far? It would be better for you to try and we can make suggestions or corrections, so you can support it/re-use it.



Kind regards,
Robin

Last edited by rbatte1; 11-23-2017 at 08:41 AM.. Reason: Typo correction
# 5  
Old 11-21-2017
Underscores are part of the name.
I didn't try anything Smilie
My idea was to call the content of the file as arguments of the mkdir function. But maybe your loop idea is better.
Don't know how to do it.
Should I read "Bash for dummies"?
# 6  
Old 11-21-2017
For a not too long list, and no whitespace in the directory names, how about
Code:
mkdir $(paste -sd' ' file)

# 7  
Old 11-21-2017
How about:
Code:
xargs mkdir < inputfile

This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Switching between directories and mkdir/copy dir/file

I was trying to copy the files inside the path /home/user/check/Q1/dir/folder1/expected/n/a1.out1 and a1.out2 and a1.out3 to /home/user/check/Q2/dir/folder1/expected/n/ if n directory is not present at Q2/dir/folder1/expected/ then directory should be created first. And, script follow the... (5 Replies)
Discussion started by: Mannu2525
5 Replies

2. Shell Programming and Scripting

Copy of "How to create a long list of directories with mkdir?"

To bakunin and corona688: My result when text in file is ms_ww_546 ms_rrL_99999 ms_nnn_67_756675 is https://www.unix.com/C:\Users\Fejoz\Desktop\ttt.jpg I hope you can see the picture. There is like a "whitespace character" after 2 of the 3 created directories. ---------- Post... (0 Replies)
Discussion started by: setub
0 Replies

3. Shell Programming and Scripting

Scan directories and create a list of files

Gents, Please can you help. I want to create a list which contends the complete patch of the location of some directories with the size of each file. need to select only .txt file In this case I am try to find the subdirectories tp1 and tp2 and create the output list. jd175-1 tp1... (3 Replies)
Discussion started by: jiam912
3 Replies

4. Shell Programming and Scripting

Make directories containing subdirs using mkdir

Hello everybody, I wonder if there's a way to make a directory that contains multiple subdirectories. For example, if I want to make /home/student under the current working directory, how do I do it? Can I do it using a single mkdir command or do I have make home first, cd into it and then make... (1 Reply)
Discussion started by: Yongfeng
1 Replies

5. UNIX for Dummies Questions & Answers

Mkdir a/b/c # where a/b does not exists. is it possible to create it ?

Is is possible to create the directories in following manner. for example my home dir is empty and i want to create dir a/b/c mkdir a/b/c # where a/b does not exists. (5 Replies)
Discussion started by: anandgodse
5 Replies

6. Shell Programming and Scripting

Need Help Moving Long List Of Files Into Directories

I am very new to BASH and I am having difficulties moving a long list of image files into similarly named directories. I've been trying to come with a script all night and no luck. Here is what my list of files looks like: DSC_0059_01.jpg DSC_0059_02.jpg DSC_0059_03.jpg DSC_0059_04.jpg... (5 Replies)
Discussion started by: jowens1138
5 Replies

7. Shell Programming and Scripting

Create unique tar archives from a list of directories

I'm looking to archive a client directory from a CIFS share There are multiple directories that will be stored in a text file and I'm looking to create an individual tar archive of each folder in the directory. I've tried a number of commands to no avail. Here's what I would like. ... (2 Replies)
Discussion started by: Steelysteel
2 Replies

8. UNIX and Linux Applications

mkdir: cannot create directory

Hi, I have network mount on two servers. One server I can create any directories without any issues, other server with the similar mount, I am not able to create directories starting with number! Creation, name start with a number: $ mkdir 1212 mkdir: cannot create directory `1212': No such... (12 Replies)
Discussion started by: ./hari.sh
12 Replies

9. AIX

mkdir: A file or path name is too long

Hi, I have an AIX machine. I am trying to create a directory from within the script, but the message being shown is "mkdir: 0653-358 Cannot create directory 'xxx': A file or path name is too long" I am not giving any 'long' pathname to mkdir. The commands being issued within the script are: ... (0 Replies)
Discussion started by: greenhorn007
0 Replies
Login or Register to Ask a Question