Shell/terminal/bash command or script for copying list of files from one project to another

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Let's say I have a project called my-project/ that lives in it's own directory and has the following file structure.



my-project/

.
├── src
│ ├── index.html
│ ├── main.js
│ ├── normalize.js
│ ├── routes
│ │ ├── index.js
│ │ └── Home
│ │ ├── index.js
│ │ └── assets
│ ├── static
│ ├── store
│ │ ├── createStore.js
│ │ └── reducers.js
│ └── styles
└── project.config.js


Now let's say I have a new project called my-new-project that also lives in it's own directory and has the same file structure as my-project but it contains an additional file called my-files-to-copy.txt



my-new-project/

.
├── src
│ ├── index.html
│ ├── main.js
│ ├── normalize.js
│ ├── routes
│ │ ├── index.js
│ │ └── Home
│ │ ├── index.js
│ │ └── assets
│ ├── static
│ ├── store
│ │ ├── createStore.js
│ │ └── reducers.js
│ └── styles
├── project.config.js
└── my-files-to-copy.txt # new file added to tree


my-new-project/ has the same file structure but different file contents than my-project/



Now let's say my-files-to-copy.txt contains a list of files I want to copy from my-project/ and write to the same path in my-new-project/ to overwrite the existing files in my-new-project/ at those locations.



my-files-to-copy.txt

src/main.js
src/routes/index.js
src/store/reducers.js
project.config.js


How can I accomplish this with a terminal/bash/shell command or script?



I think I might be able to do:



cp my-project/src/main.js my-new-project/src/main.js
cp my-project/src/routes/index.js my-new-project/src/routes/index.js
cp my-project/src/store/reducers.js my-new-project/src/store/reducers.js
cp my-project/project.config.js my-new-project/project.config.js


Maybe some type of rsync command will do?



But as the number of files scales, this method will become less efficient. I was looking for a more efficient solution that would allow me to leverage the file that contains the list of files (or at least a script) without having to write a separate command for each one.










share|improve this question

























    up vote
    0
    down vote

    favorite












    Let's say I have a project called my-project/ that lives in it's own directory and has the following file structure.



    my-project/

    .
    ├── src
    │ ├── index.html
    │ ├── main.js
    │ ├── normalize.js
    │ ├── routes
    │ │ ├── index.js
    │ │ └── Home
    │ │ ├── index.js
    │ │ └── assets
    │ ├── static
    │ ├── store
    │ │ ├── createStore.js
    │ │ └── reducers.js
    │ └── styles
    └── project.config.js


    Now let's say I have a new project called my-new-project that also lives in it's own directory and has the same file structure as my-project but it contains an additional file called my-files-to-copy.txt



    my-new-project/

    .
    ├── src
    │ ├── index.html
    │ ├── main.js
    │ ├── normalize.js
    │ ├── routes
    │ │ ├── index.js
    │ │ └── Home
    │ │ ├── index.js
    │ │ └── assets
    │ ├── static
    │ ├── store
    │ │ ├── createStore.js
    │ │ └── reducers.js
    │ └── styles
    ├── project.config.js
    └── my-files-to-copy.txt # new file added to tree


    my-new-project/ has the same file structure but different file contents than my-project/



    Now let's say my-files-to-copy.txt contains a list of files I want to copy from my-project/ and write to the same path in my-new-project/ to overwrite the existing files in my-new-project/ at those locations.



    my-files-to-copy.txt

    src/main.js
    src/routes/index.js
    src/store/reducers.js
    project.config.js


    How can I accomplish this with a terminal/bash/shell command or script?



    I think I might be able to do:



    cp my-project/src/main.js my-new-project/src/main.js
    cp my-project/src/routes/index.js my-new-project/src/routes/index.js
    cp my-project/src/store/reducers.js my-new-project/src/store/reducers.js
    cp my-project/project.config.js my-new-project/project.config.js


    Maybe some type of rsync command will do?



    But as the number of files scales, this method will become less efficient. I was looking for a more efficient solution that would allow me to leverage the file that contains the list of files (or at least a script) without having to write a separate command for each one.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Let's say I have a project called my-project/ that lives in it's own directory and has the following file structure.



      my-project/

      .
      ├── src
      │ ├── index.html
      │ ├── main.js
      │ ├── normalize.js
      │ ├── routes
      │ │ ├── index.js
      │ │ └── Home
      │ │ ├── index.js
      │ │ └── assets
      │ ├── static
      │ ├── store
      │ │ ├── createStore.js
      │ │ └── reducers.js
      │ └── styles
      └── project.config.js


      Now let's say I have a new project called my-new-project that also lives in it's own directory and has the same file structure as my-project but it contains an additional file called my-files-to-copy.txt



      my-new-project/

      .
      ├── src
      │ ├── index.html
      │ ├── main.js
      │ ├── normalize.js
      │ ├── routes
      │ │ ├── index.js
      │ │ └── Home
      │ │ ├── index.js
      │ │ └── assets
      │ ├── static
      │ ├── store
      │ │ ├── createStore.js
      │ │ └── reducers.js
      │ └── styles
      ├── project.config.js
      └── my-files-to-copy.txt # new file added to tree


      my-new-project/ has the same file structure but different file contents than my-project/



      Now let's say my-files-to-copy.txt contains a list of files I want to copy from my-project/ and write to the same path in my-new-project/ to overwrite the existing files in my-new-project/ at those locations.



      my-files-to-copy.txt

      src/main.js
      src/routes/index.js
      src/store/reducers.js
      project.config.js


      How can I accomplish this with a terminal/bash/shell command or script?



      I think I might be able to do:



      cp my-project/src/main.js my-new-project/src/main.js
      cp my-project/src/routes/index.js my-new-project/src/routes/index.js
      cp my-project/src/store/reducers.js my-new-project/src/store/reducers.js
      cp my-project/project.config.js my-new-project/project.config.js


      Maybe some type of rsync command will do?



      But as the number of files scales, this method will become less efficient. I was looking for a more efficient solution that would allow me to leverage the file that contains the list of files (or at least a script) without having to write a separate command for each one.










      share|improve this question













      Let's say I have a project called my-project/ that lives in it's own directory and has the following file structure.



      my-project/

      .
      ├── src
      │ ├── index.html
      │ ├── main.js
      │ ├── normalize.js
      │ ├── routes
      │ │ ├── index.js
      │ │ └── Home
      │ │ ├── index.js
      │ │ └── assets
      │ ├── static
      │ ├── store
      │ │ ├── createStore.js
      │ │ └── reducers.js
      │ └── styles
      └── project.config.js


      Now let's say I have a new project called my-new-project that also lives in it's own directory and has the same file structure as my-project but it contains an additional file called my-files-to-copy.txt



      my-new-project/

      .
      ├── src
      │ ├── index.html
      │ ├── main.js
      │ ├── normalize.js
      │ ├── routes
      │ │ ├── index.js
      │ │ └── Home
      │ │ ├── index.js
      │ │ └── assets
      │ ├── static
      │ ├── store
      │ │ ├── createStore.js
      │ │ └── reducers.js
      │ └── styles
      ├── project.config.js
      └── my-files-to-copy.txt # new file added to tree


      my-new-project/ has the same file structure but different file contents than my-project/



      Now let's say my-files-to-copy.txt contains a list of files I want to copy from my-project/ and write to the same path in my-new-project/ to overwrite the existing files in my-new-project/ at those locations.



      my-files-to-copy.txt

      src/main.js
      src/routes/index.js
      src/store/reducers.js
      project.config.js


      How can I accomplish this with a terminal/bash/shell command or script?



      I think I might be able to do:



      cp my-project/src/main.js my-new-project/src/main.js
      cp my-project/src/routes/index.js my-new-project/src/routes/index.js
      cp my-project/src/store/reducers.js my-new-project/src/store/reducers.js
      cp my-project/project.config.js my-new-project/project.config.js


      Maybe some type of rsync command will do?



      But as the number of files scales, this method will become less efficient. I was looking for a more efficient solution that would allow me to leverage the file that contains the list of files (or at least a script) without having to write a separate command for each one.







      bash shell-script shell terminal






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Mowzer

      155227




      155227




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          This is what cpio is for: copying a list of files. I always find the "in" and "out directions confusing and am glad the GNU one has --create and --extract.



           cd your/source/dir
          cpio --create < my-files-to-copy.txt | (cd your/dest/dir && cpio --extract)


          There are lots of options for cpio to govern things like preserving ownership / timestamps. The man page will guide you. One big gotcha to know about is cpio will not create directories unless you (a) copy them to the stream (eg in your list of files to copy) or (b) use the --make-directories option on the extract side.






          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',
            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%2f481036%2fshell-terminal-bash-command-or-script-for-copying-list-of-files-from-one-project%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            This is what cpio is for: copying a list of files. I always find the "in" and "out directions confusing and am glad the GNU one has --create and --extract.



             cd your/source/dir
            cpio --create < my-files-to-copy.txt | (cd your/dest/dir && cpio --extract)


            There are lots of options for cpio to govern things like preserving ownership / timestamps. The man page will guide you. One big gotcha to know about is cpio will not create directories unless you (a) copy them to the stream (eg in your list of files to copy) or (b) use the --make-directories option on the extract side.






            share|improve this answer
























              up vote
              0
              down vote













              This is what cpio is for: copying a list of files. I always find the "in" and "out directions confusing and am glad the GNU one has --create and --extract.



               cd your/source/dir
              cpio --create < my-files-to-copy.txt | (cd your/dest/dir && cpio --extract)


              There are lots of options for cpio to govern things like preserving ownership / timestamps. The man page will guide you. One big gotcha to know about is cpio will not create directories unless you (a) copy them to the stream (eg in your list of files to copy) or (b) use the --make-directories option on the extract side.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                This is what cpio is for: copying a list of files. I always find the "in" and "out directions confusing and am glad the GNU one has --create and --extract.



                 cd your/source/dir
                cpio --create < my-files-to-copy.txt | (cd your/dest/dir && cpio --extract)


                There are lots of options for cpio to govern things like preserving ownership / timestamps. The man page will guide you. One big gotcha to know about is cpio will not create directories unless you (a) copy them to the stream (eg in your list of files to copy) or (b) use the --make-directories option on the extract side.






                share|improve this answer












                This is what cpio is for: copying a list of files. I always find the "in" and "out directions confusing and am glad the GNU one has --create and --extract.



                 cd your/source/dir
                cpio --create < my-files-to-copy.txt | (cd your/dest/dir && cpio --extract)


                There are lots of options for cpio to govern things like preserving ownership / timestamps. The man page will guide you. One big gotcha to know about is cpio will not create directories unless you (a) copy them to the stream (eg in your list of files to copy) or (b) use the --make-directories option on the extract side.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                Cupcake Protocol

                1464




                1464



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481036%2fshell-terminal-bash-command-or-script-for-copying-list-of-files-from-one-project%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?