Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 10-29-2005, 09:37 PM   #1 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 94

neo214

Send a message via AIM to neo214
Default Linux/UNIX command help

What would be the command to create 3 directories and then create files within all of them?

I know it would be mkdir, then touch files, but how would you get all of this done in one command?
__________________
Later!
neo214 is offline  
Old 10-29-2005, 09:42 PM   #2 (permalink)
macdude425's Avatar
 
Member (again)

Join Date: Jan 2005

Location: Raul's Wild Kingdom...How 'bout that, huh?

Posts: 4,200

macdude425 is on a distinguished road

Send a message via AIM to macdude425 Send a message via Yahoo to macdude425
Default

IF you can use &&, which puts multiple commands together in one, then you can do mkdir blah && mkdir blah2 && mkdir blah3, etc.
__________________



Debian Support Forums!
macdude425 is offline  
Old 10-29-2005, 10:18 PM   #3 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 94

neo214

Send a message via AIM to neo214
Default

Ahh, so that would be nesting the commands, like to say mkdir "THEN" do this "THEN" do this?

So far I have something like mkdir os{001,002,800}

that would make the three directories, but I have to put four files log_2005oct{28-31} into each one of them.

Okay log_2005oct{28-31} does not work it has to be:

touch os_2005oct{28,29,30,31}
__________________
Later!
neo214 is offline  
Old 10-29-2005, 10:36 PM   #4 (permalink)
 
Master Techie

Join Date: Apr 2004

Posts: 2,534

horndude is on a distinguished road

Default

mkdir dir1 dir2 dir3; touch dir1/file1 dir2/file2 dir3/file3
horndude is offline  
Old 10-30-2005, 11:16 AM   #5 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 94

neo214

Send a message via AIM to neo214
Default

So a semicolin will nest commands (or sequence them so they will come out after another?
__________________
Later!
neo214 is offline  
Old 10-30-2005, 11:23 AM   #6 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 94

neo214

Send a message via AIM to neo214
Default

Quote:
Originally posted by horndude
mkdir dir1 dir2 dir3; touch dir1/file1 dir2/file2 dir3/file3
Others said it could not be done!

you did it, you my friend earn my person of the day award

You are also the master of the shell

But really thanks man you rule! with a simple slash mark you have brightened my day )))
__________________
Later!
neo214 is offline  
Old 10-30-2005, 11:46 AM   #7 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 94

neo214

Send a message via AIM to neo214
Default

mkdir os{001,002,800}; touch os{001,002,800}/log_2005oct{28,29,30,31}; chmod +rwx os{001,002,800}/log_2005oct{28,29,30,31}

was my final answer thanks! it works!
__________________
Later!
neo214 is offline  
Old 10-30-2005, 12:21 PM   #8 (permalink)
 
Master Techie

Join Date: Apr 2004

Posts: 2,534

horndude is on a distinguished road

Default

semicolons nest commands or chain them together on the commandline

the / is what bash shell and linux in general uses for directory separators-----just like in DOS or windows, only they use the backslash--> \

you could have used a loop as well:
for i in 28 29 30 31;do mkdir ~blah blah blah~;done
horndude is offline  
 
Closed Thread

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On