Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 12-07-2012, 07:48 PM   #1
LQ Newbie
Registered: Dec 2012
Posts: 9

Rep: Reputation: Disabled
Making directories for each directory???

So here is a question on my UNIX homework:

Using a for loop, write a program to automatically create a directory under your hw9 directory for each directory under the root directory.

hint: `ls /`

But I have no idea where to start! You don't have to "give" me the answer if you dont want to, but I feel like this question is way over my head. I dont know what Im doing.. Please help
Old 12-07-2012, 07:58 PM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
So----what commands have you studied? e.g.:

Do you know the basic command for creating a directory?
Do you know how to list the contents of a directory?
Do you know the basic structure of a "for loop"?

You program will probably go something like this:
in the for loop, read thru the results of a listing of directory A. For each time thru the loop, read the name of a directory (or file) into a variable, then use that variable to create a new directory or file in directory B.
Old 12-08-2012, 12:35 AM   #3
Senior Member
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,260

Rep: Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421
Originally Posted by kross2100 View Post
hint: `ls /`
Hint: don't use ls.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a directory into another directory while ignoring specific directories or files wh33t Linux - Newbie 14 05-16-2012 09:13 PM
Copying files and sub-directories of a directory except the directories named ".abc" sri1025 Linux - General 2 08-24-2010 09:53 AM
Count the number of files in a directory and sub-directories within that directory soumyajit.haldar Linux - Software 4 03-20-2007 07:22 AM
Bash script to strip a certain directory out of directories in a directory? rylan76 Linux - General 3 08-29-2006 12:35 PM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 07:54 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:20 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration