I have 3 commands to create the folders necessary in a Makefile:

    install -d $(DESTDIR)/usr/lib/app
    install -d $(DESTDIR)/usr/lib/app/scripts
    install -d $(DESTDIR)/usr/lib/app/scripts/network-service

Is there a flag I can use to put this into a single line?


Only the last command should be necessary. install -d will create the missing intermediate directories:

install -d "$(DESTDIR)/usr/lib/app/scripts/network-service"

From the GNU install manual:

-d, --directory

treat all arguments as directory names; create all components of the specified directories

For what it's worth, BSD install also works like this:


Create directories. Missing parent directories are created as required. This option cannot be used with the -B, -b, -C, -c, -f, -p, -S, or -s options.

  • doh, I should have tried that before asking. The code I'm working on already had the above so I just assumed it was needed like with mkdir /folder/in/folder. – Philip Kirkbride Nov 2 '17 at 16:07
  • 1
    @PhilipKirkbride install -d works like mkdir -p in this respect. – Kusalananda Nov 2 '17 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.