Linux Magic

Spread the love

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.

Have you read the breakthrough novel of the year? When you are done with that, try:

In Search of Sungudogo by Greg Laden, now in Kindle or Paperback
*Please note:
Links to books and other items on this page and elsewhere on Greg Ladens' blog may send you to Amazon, where I am a registered affiliate. As an Amazon Associate I earn from qualifying purchases, which helps to fund this site.

Spread the love

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.

  2. Beware the power of xargs.sed -e ‘s/(.)//1/g’ -e ‘s/^/words/’ /usr/dict/words | xargs mkdir -p

Leave a Reply to Jeff Darcy Cancel reply

Your email address will not be published. Required fields are marked *