Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
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.
I would like to create let say 100 folders inside every folders there has to be a text file plus 1 more folder and that folder has to have a spicific
name as well . I would like to do this through a list in a text file so piping would be in folded.
Is this possible or do I have to write a bash file for all of this.
There is probably a convoluted regexp for this, but the script method is best, yes.
You'd step through the list, create the directory, cd into it, create the subdirectory and text file, cd up, go to next line on the list.
This sounds like a homework assignment. It's your responsibility to do your homework.
What you want to do is possible using shell scripting. Two good resources to read to help you complete your assignment are: The Absolute Bash-scripting Guide and the Bash Guide for Beginners. Both can be found on the internet.
Maybe something like:
for i in < list.txt
do
mkdir $i
done
Using redirect to input the names from the list of names to use (one name per line in the list). You should realize that this will work in your home directory when logged in as user. To create the directories elswhere, the script will have to run with root authority.
This would work as the outer loop to create the topmost directory, then nest an inner loop to create the inner folder and text file.
Last edited by bigrigdriver; 02-20-2008 at 04:00 AM.
Responses to posts often reflect the experience level of the person making the suggestion. Case in point: my contribution reflects beginner level scripting skills; Quigi's response reflects a more advanced skill level.
But both illustrate a truism in GNU/Linux: there is more that one way to get the job done.
Thanks, Quigi. My knowledge has increased thanks to your suggestion.
Or, if there is any truth in a favorite fantasy of mine: I'm really a top-notch script writer, but I tailored my response to my perceived skill level of the person who posted the problem.
Hmmm. Is he, or isn't he.
Last edited by bigrigdriver; 02-20-2008 at 02:45 PM.
I would like to create let say 100 folders inside every folders there has to be a text file plus 1 more folder and that folder has to have a spicific name as well .
What relationship do the names of the parent folder, the text file, & the sub-folder have to each other?
Examples wouldn't hurt.
Do the text files have to have content, or just get created?
Quote:
Originally Posted by JJV
I would like to do this through a list in a text file so piping would be in folded.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.