Register
Members List
Social Groups
Search
Today's Posts
Mark Forums Read
Member Login
Remember Me?
Sign Up!
|
Forgot Password
Computer Forums
>
PC Technology Zone
>
Linux, BSD, other *nixes & Open Source Software
» Linux/UNIX command help
LinkBack
Thread Tools
Display Modes
10-29-2005, 09:37 PM
#
1
(
permalink
)
neo214
Junior Techie
Join Date: Mar 2005
Posts: 94
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!
10-29-2005, 09:42 PM
#
2
(
permalink
)
macdude425
Member (again)
Join Date: Jan 2005
Location: Raul's Wild Kingdom...How 'bout that, huh?
Posts: 4,200
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!
10-29-2005, 10:18 PM
#
3
(
permalink
)
neo214
Junior Techie
Join Date: Mar 2005
Posts: 94
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!
10-29-2005, 10:36 PM
#
4
(
permalink
)
horndude
Master Techie
Join Date: Apr 2004
Posts: 2,534
mkdir dir1 dir2 dir3; touch dir1/file1 dir2/file2 dir3/file3
10-30-2005, 11:16 AM
#
5
(
permalink
)
neo214
Junior Techie
Join Date: Mar 2005
Posts: 94
So a semicolin will nest commands (or sequence them so they will come out after another?
__________________
Later!
10-30-2005, 11:23 AM
#
6
(
permalink
)
neo214
Junior Techie
Join Date: Mar 2005
Posts: 94
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!
10-30-2005, 11:46 AM
#
7
(
permalink
)
neo214
Junior Techie
Join Date: Mar 2005
Posts: 94
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!
10-30-2005, 12:21 PM
#
8
(
permalink
)
horndude
Master Techie
Join Date: Apr 2004
Posts: 2,534
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
«
DVD Player won't show up...
|
SuSE 9.1 and speakers
»
Thread Tools
Show Printable Version
Email this Page
Display Modes
Linear Mode
Switch to Hybrid Mode
Switch to Threaded Mode
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
Forum Rules
Contact Us
-
Computer Technology Forums
-
Archive
-
Top
LinkBack
LinkBack URL
About LinkBacks
Bookmark & Share
Digg this Thread!
Add Thread to del.icio.us
Bookmark in Technorati
Furl this Thread!