Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create tree in one command

Status
Not open for further replies.

greyone

Programmer
Dec 14, 2000
200
0
0
CA
Hi guys
is it possible to create the following directory tree in one command

~
|
|
________________________________|_______________________

| | |
AA 11 A1
| | |
BB 22 B2
| | |
CC 33 C3

Thanks
Nitin
 
Try this ( I started you with AA,11 and you can add the a1 directory and subdirectories to the script):

#!/bin/ksh
i=`mkdir AA 11;cd AA;mkdir BB;cd BB;mkdir CC;cd ../../11;mkdir 22;cd 22;mkdir 33`
echo $i

Then execute the script.
 
but that's like many commands. Is it possible to just use mkdir command to make the tree. Is there some recursive option by which i can create this listing recursivly.

Thanks
iitn

























 
The badco script is really a combination of commands put into one script with no arguments, so technically if you ran the script with no arguments it should do what you requested.


Here is the one command (where scriptname is the name of badco script):

UnixPrompt# scriptname

 
i was reading up somewhere that in order to make directories recursively we can use the -p option as follows

mkdir -p aa/bb/cc

the above command will create the directory cc under bb and bb under cc. So is there a way to work on this option to solve the problem

Thanks
Nitin
 
Extract from man page for mkdir:

EXAMPLES
Example 1: Using mkdir

The following example:

example% mkdir -p ltr/jd/jan
creates the subdirectory structure ltr/jd/jan.

Bea in mind that this is Solaris - other flavours may be different.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top