GNU “install” -d flag — how's it work?












26















I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.



In the manpage, it says:




SYNOPSIS



   install [OPTION]... [-T] SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...

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



OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?



I tried doing a basic test by making an arbitrary directory structure on my local hard disk:



~>tree test
test
├── a
│   └── b
│   └── c
│   └── e.txt
└── d

4 directories, 1 file


And then running install -d and looking at what was created:



~>install -d test test2
~>tree test2
test2

0 directories, 0 files


Nothing happened!



Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.










share|improve this question





























    26















    I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.



    In the manpage, it says:




    SYNOPSIS



       install [OPTION]... [-T] SOURCE DEST
    install [OPTION]... SOURCE... DIRECTORY
    install [OPTION]... -t DIRECTORY SOURCE...
    install [OPTION]... -d DIRECTORY...

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



    OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?



    I tried doing a basic test by making an arbitrary directory structure on my local hard disk:



    ~>tree test
    test
    ├── a
    │   └── b
    │   └── c
    │   └── e.txt
    └── d

    4 directories, 1 file


    And then running install -d and looking at what was created:



    ~>install -d test test2
    ~>tree test2
    test2

    0 directories, 0 files


    Nothing happened!



    Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.










    share|improve this question



























      26












      26








      26


      2






      I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.



      In the manpage, it says:




      SYNOPSIS



         install [OPTION]... [-T] SOURCE DEST
      install [OPTION]... SOURCE... DIRECTORY
      install [OPTION]... -t DIRECTORY SOURCE...
      install [OPTION]... -d DIRECTORY...

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



      OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?



      I tried doing a basic test by making an arbitrary directory structure on my local hard disk:



      ~>tree test
      test
      ├── a
      │   └── b
      │   └── c
      │   └── e.txt
      └── d

      4 directories, 1 file


      And then running install -d and looking at what was created:



      ~>install -d test test2
      ~>tree test2
      test2

      0 directories, 0 files


      Nothing happened!



      Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.










      share|improve this question
















      I'm trying to write a makefile rule to copy a directory, maintaining its structure, and since all the other rules in our makefiles use install, I wanted to be consistent.



      In the manpage, it says:




      SYNOPSIS



         install [OPTION]... [-T] SOURCE DEST
      install [OPTION]... SOURCE... DIRECTORY
      install [OPTION]... -t DIRECTORY SOURCE...
      install [OPTION]... -d DIRECTORY...

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



      OK, that sounds like what I need... but the flags don't make sense. How do you specify the destination directory to install to?



      I tried doing a basic test by making an arbitrary directory structure on my local hard disk:



      ~>tree test
      test
      ├── a
      │   └── b
      │   └── c
      │   └── e.txt
      └── d

      4 directories, 1 file


      And then running install -d and looking at what was created:



      ~>install -d test test2
      ~>tree test2
      test2

      0 directories, 0 files


      Nothing happened!



      Can anyone point me in the right direction? Googling "gnu install -d flag" isn't bringing me much.







      coreutils






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 22 '14 at 16:16









      derobert

      74.5k8162216




      74.5k8162216










      asked Sep 22 '11 at 15:30









      ashgromniesashgromnies

      411148




      411148






















          3 Answers
          3






          active

          oldest

          votes


















          18














          It looks like the install -D command is actually what I want.



          Manpage:




          -D create all leading components of DEST except the last, then copy SOURCE to DEST




          Works great, except you have to specify every file individually.






          share|improve this answer



















          • 8





            I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

            – dtmland
            Jul 8 '15 at 20:11








          • 5





            Does the install command have an equivalent to cp -r?

            – Alexander
            Jul 8 '16 at 10:53



















          13














          install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp






          share|improve this answer



















          • 2





            Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

            – ZiggyTheHamster
            Aug 28 '17 at 19:40



















          0














          Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY



          find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21260%2fgnu-install-d-flag-hows-it-work%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            18














            It looks like the install -D command is actually what I want.



            Manpage:




            -D create all leading components of DEST except the last, then copy SOURCE to DEST




            Works great, except you have to specify every file individually.






            share|improve this answer



















            • 8





              I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

              – dtmland
              Jul 8 '15 at 20:11








            • 5





              Does the install command have an equivalent to cp -r?

              – Alexander
              Jul 8 '16 at 10:53
















            18














            It looks like the install -D command is actually what I want.



            Manpage:




            -D create all leading components of DEST except the last, then copy SOURCE to DEST




            Works great, except you have to specify every file individually.






            share|improve this answer



















            • 8





              I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

              – dtmland
              Jul 8 '15 at 20:11








            • 5





              Does the install command have an equivalent to cp -r?

              – Alexander
              Jul 8 '16 at 10:53














            18












            18








            18







            It looks like the install -D command is actually what I want.



            Manpage:




            -D create all leading components of DEST except the last, then copy SOURCE to DEST




            Works great, except you have to specify every file individually.






            share|improve this answer













            It looks like the install -D command is actually what I want.



            Manpage:




            -D create all leading components of DEST except the last, then copy SOURCE to DEST




            Works great, except you have to specify every file individually.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 22 '11 at 15:48









            ashgromniesashgromnies

            411148




            411148








            • 8





              I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

              – dtmland
              Jul 8 '15 at 20:11








            • 5





              Does the install command have an equivalent to cp -r?

              – Alexander
              Jul 8 '16 at 10:53














            • 8





              I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

              – dtmland
              Jul 8 '15 at 20:11








            • 5





              Does the install command have an equivalent to cp -r?

              – Alexander
              Jul 8 '16 at 10:53








            8




            8





            I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

            – dtmland
            Jul 8 '15 at 20:11







            I was excited right up until the end, "you have to specify every file individually". Guess I'll stick with cp -r

            – dtmland
            Jul 8 '15 at 20:11






            5




            5





            Does the install command have an equivalent to cp -r?

            – Alexander
            Jul 8 '16 at 10:53





            Does the install command have an equivalent to cp -r?

            – Alexander
            Jul 8 '16 at 10:53













            13














            install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp






            share|improve this answer



















            • 2





              Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

              – ZiggyTheHamster
              Aug 28 '17 at 19:40
















            13














            install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp






            share|improve this answer



















            • 2





              Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

              – ZiggyTheHamster
              Aug 28 '17 at 19:40














            13












            13








            13







            install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp






            share|improve this answer













            install -d is just used to create directories. You told it to create two directories, test and test2. test already existed, so all it needed to do was make test2. I don't think install supports copying entire directory trees; it's normally used on files. You probably need to use cp







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 22 '11 at 15:44









            Michael MrozekMichael Mrozek

            61.7k29192211




            61.7k29192211








            • 2





              Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

              – ZiggyTheHamster
              Aug 28 '17 at 19:40














            • 2





              Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

              – ZiggyTheHamster
              Aug 28 '17 at 19:40








            2




            2





            Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

            – ZiggyTheHamster
            Aug 28 '17 at 19:40





            Basically, install -d is the same as mkdir except that you can specify the mode, owner, SELinux context, and group all at once.

            – ZiggyTheHamster
            Aug 28 '17 at 19:40











            0














            Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY



            find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;





            share|improve this answer




























              0














              Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY



              find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;





              share|improve this answer


























                0












                0








                0







                Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY



                find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;





                share|improve this answer













                Usually what you want is to install files at right folder, without repeating your self. You can use find and install to help to keep your installation scripts more DRY



                find SOURCE/ -type f -exec install -vDm 755 {} THERE/{} ;






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 39 mins ago









                geckosgeckos

                1412




                1412






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21260%2fgnu-install-d-flag-hows-it-work%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Histoire des bourses de valeurs

                    Why is there Russian traffic in my log files?

                    Rename multiple files to decrement number in file name?