Linux Magic

Let’s say you want to make a directory tree in Linux a few directories deep. You could do this:greg@greg-laptop:~$ mkdir tstgreg@greg-laptop:~$ cd tstgreg@greg-laptop:~/tst$ mkdir tstdeepergreg@greg-laptop:~/tst$ cd tstdeepergreg@greg-laptop:~/tst/tstdeeper$ mkdir evendeepergreg@greg-laptop:~/tst/tstdeeper$ cd evendeepergreg@greg-laptop:~/tst/tstdeeper/evendeeper$Or, you could be smart and do this:greg@greg-laptop:~$ mkdir -p tst/tstdeeper/evendeeperNotice the -p option.

Share and Enjoy:
  • Twitter
  • StumbleUpon
  • Facebook
  • Digg
  • Yahoo! Buzz
  • Google Bookmarks
  • LinkedIn

5 thoughts on “Linux Magic

  1. 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.

Leave a Reply

Your email address will not be published.