Creating named directories from a list of names


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Creating named directories from a list of names
# 1  
Old 08-18-2011
Bug Creating named directories from a list of names

Hi There,

I'm a competent computer user that is learning basic unix commands.

This is a slightly hypothetical question (for now at least!) but I can see a need for doing something like this in the near future.

So I recently learned this command mkdir foo{1..100} which of course create's 100 sequentially numbered directories quite remarkable considering how much time it would take to using the GUI (OSX in my case).

Lets assume I wanted to now create the same amount of directories but named from a list of names contained within a file. The actual file type is not relevant for now, because in the future I can make sure it is in the file type which is "easiest" to run this type of command, lets for arguments sake say it's a .txt file with a format like this

Jim Jones
Jayne Doe
John Smith
Jack Daniels

etc

Can anybody help with this type of command. I have searched the net and a few forums but have found nothing. I suppose this type of question might be easily answered by a unix / linux sys admin that might have to create directories like this for a school / university / organisation.

Thanks in advance

James
# 2  
Old 08-18-2011
Code:
while read L; do mkdir "$L"; done < listfile

# 3  
Old 08-18-2011
Home work?
# 4  
Old 08-18-2011
Thanks I will give this a try.

"Home Work?" - I'm 26 my university days are long behind me in another field too. I like to write my questions with care!

Thanks I will post back with my findings.

James
# 5  
Old 08-18-2011
Generally for future postings please use [code] and [/code] tags when posting code, data, lists or logs etc. to preserve formatting and enhance readability, thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

2. Shell Programming and Scripting

Want to remove directories names 1 2 3 ...

Dear All, I have some list of directories names 1 2 3 .... n. Number can vary each time when I run some software to create these folders. When ever I wanted to run new case I have to remove all the sub-directories named 1 2 3 4 .... in case directory. How can I do it using rm -r command? ... (4 Replies)
Discussion started by: linuxUser_
4 Replies

3. UNIX for Dummies Questions & Answers

List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, having given pattern in the directories name, sorted by creation date. Example: Directories with name "pkg32*" or "pkg33*" 2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies

4. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

5. Shell Programming and Scripting

Creating usernames from a list of names

Hello everyone, I am trying to create a script that will make usernames (last name and first letter of name - for example, James Bond = bondj). At this point, I figured out how to make a script that can read the list of names from a text file. Here is what I have: #!/bin/bash ... (5 Replies)
Discussion started by: RSpades
5 Replies

6. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

7. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

8. Shell Programming and Scripting

Copying a files from a filter list and creating their associated parent directories

Hello all, I'm trying to copy all files within a specified directory to another location based on a find filter of mtime -1 (Solaris OS). The issue that I'm having is that in the destination directory, I want to retain the source directory structure while copying over only the files that have... (4 Replies)
Discussion started by: hunter55
4 Replies

9. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

10. Shell Programming and Scripting

Compare File Names in Different Directories...

I do not know much about shell scripting and need to create a script and I am at a loss. If someone can help me, that would be great!! I have two directories: /dir1 /dir2 I need to get the sequence number which is part of the filename in /dir1 and delete all files in /dir2 that are... (4 Replies)
Discussion started by: stky13
4 Replies
Login or Register to Ask a Question