Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-29-2004, 03:09 PM
|
#1
|
Member
Registered: Nov 2002
Location: Rio Rancho, NM
Distribution: RHEL, CentOS & Ubuntu
Posts: 90
Rep:
|
mkdir script
I have a file that contains 100 directories I need to create. I would rather have some sort of script read the file and create each directory than typing it by hand. The file that contains the names is setup with one directory name per line. Suggestions? Thanks
|
|
|
11-29-2004, 03:11 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Code:
for i in `cat filename`; do mkdir $i; done
and if these directories contain whitespace
Code:
OLDIFS=$IFS
IFS=$'\n'
for i in `cat filename`; do mkdir $i; done
IFS=$OLDIFS
Last edited by acid_kewpie; 11-29-2004 at 03:15 PM.
|
|
|
11-29-2004, 03:12 PM
|
#3
|
Senior Member
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197
Rep:
|
'for()' is your friend
Code:
for D `cat /path/to/file`; do
mkdir ${D};
done;
|
|
|
11-29-2004, 03:56 PM
|
#4
|
Member
Registered: Nov 2002
Location: Rio Rancho, NM
Distribution: RHEL, CentOS & Ubuntu
Posts: 90
Original Poster
Rep:
|
Excellent thank you so much. I found the for command but was unsure on how to use it.
|
|
|
All times are GMT -5. The time now is 09:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|