Now on ScienceBlogs: Oldest Human-Made Object in Space

ScienceBlogs Book Club: Inside the Outbreaks

Greg Laden's Blog

Evolution, Life Sciences, Science Education, Human Evolution, and Stuff

Darwing_Face.jpg Learn more about Charles Darwin and his work.

Hornbill170.jpg Looking for stuff about birds?

Lion_mane170.jpg Lean more about lions

Congo_sidebar.jpg An archaeological expedition to the Congo


The Skeptical Search Engine


Nature Blog Network
Climate Defense Fund


The contents of Greg Laden's Blog are copyrighted by Greg Laden.

Recent Comments

Search

Profile


Click on "About" for the big picture, and "Archives" for the details.


Recent Posts

Blogroll

If you don't see yourself on my blogroll, just drop me a line and let me know. I'll add you.*
*Assuming that I'm on your blogroll, of course!

Archives

« Joseph Lekuton: A parable for Kenya | Main | Does Apple Throttle The Competition, Microsoft Style? »

Linux Magic

Posted on: March 3, 2008 5:10 PM, by Greg Laden

Let's say you want to make a directory tree in Linux a few directories deep. You could do this:


greg@greg-laptop:~$ mkdir tst
greg@greg-laptop:~$ cd tst
greg@greg-laptop:~/tst$ mkdir tstdeeper
greg@greg-laptop:~/tst$ cd tstdeeper
greg@greg-laptop:~/tst/tstdeeper$ mkdir evendeeper
greg@greg-laptop:~/tst/tstdeeper$ cd evendeeper
greg@greg-laptop:~/tst/tstdeeper/evendeeper$

Or, you could be smart and do this:


greg@greg-laptop:~$ mkdir -p tst/tstdeeper/evendeeper

Notice the -p option.

Share on Facebook
Share on StumbleUpon
Share on Facebook
Find more posts in: Technology

TrackBacks

TrackBack URL for this entry: http://scienceblogs.com/mt/pings/65681

Comments

1

For the record, Windows does this magically -- without the need for -p.

Just saying.

Posted by: StuV | March 3, 2008 6:34 PM

2

On the other hand, windows doesn't let you use '?' or several other characters.

Posted by: kezdro | March 3, 2008 6:44 PM

3

Yet another major security hole in windows exposed!

Posted by: Greg Laden | March 3, 2008 7:19 PM

4

The other nice thing about -p is that it doesn't complain if the target exists. This makes it very useful in situations where you want to ensure a directory is there and you don't want to deal separately with the case where it is vs. the one where it isn't.

Posted by: Jeff Darcy | March 3, 2008 7:50 PM

5

Beware the power of xargs.

sed -e 's/\(.\)/\/\1/g' -e 's/^/words/' /usr/dict/words | xargs mkdir -p

Posted by: rpenner | March 3, 2008 8:02 PM

Post a Comment

(Email is required for authentication purposes only. On some blogs, comments are moderated for spam, so your comment may not appear immediately.)





ScienceBlogs

Search ScienceBlogs:

Go to:

Advertisement
Follow ScienceBlogs on Twitter

© 2006-2011 ScienceBlogs LLC. ScienceBlogs is a registered trademark of ScienceBlogs LLC. All rights reserved.