Is it possible with SCP to only copy files that match a certain date?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







7















Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?










share|improve this question































    7















    Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?










    share|improve this question



























      7












      7








      7


      5






      Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?










      share|improve this question
















      Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?







      scp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 24 '14 at 7:24









      user3085931

      1114




      1114










      asked Dec 27 '12 at 22:18









      eichoa3Ieichoa3I

      94671527




      94671527






















          2 Answers
          2






          active

          oldest

          votes


















          5














          You can't do this directly with scp. The unix way is to combine tools, you want the find command.



          Here is an example of searching for a file with a given date:



          touch --date "2007-01-01" start
          touch --date "2008-01-01" end
          find -type f -newer start -not -newer end


          I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/



          To feed this into scp you could do this:



          find -type f -newer start -not -newer end -exec scp {} dest: ;


          This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:



          scp `find -type f -newer start -not -newer end` dest:





          share|improve this answer



















          • 1





            It's easy when you copy files from client to server, but what about the other way around?

            – Petr Peller
            Mar 30 '14 at 18:14






          • 2





            @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

            – Edward Betts
            Mar 31 '14 at 11:11





















          0














          An effective (one-line !) alternative (by @sudodus) is given here, which copies through an SSH channel using 'cpio' in copy-out mode. You can tailor the find arguments as you need, perhaps using the time/min/newer tests.



          To get your exact date & time test, create a dummy file with the correct time & date on your source system, use the find -newer test, or use the man page's -newerXY test. See https://linux.die.net/man/1/find



          The output of the find command running on the remote system is piped back to the local system securely via ssh, and saved.



          It appears to do all you require, but does not use 'scp' - which might affect your marking. But it does use a combination of Unix tools - which is the Unix approach !



          In any case, scp is a shortcut for the most common cases, this approach is more powerful, when filtering of files is required.



          ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )


          https://askubuntu.com/questions/1080590/how-to-use-find-in-scp-command






          share|improve this answer


























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fsuperuser.com%2fquestions%2f524974%2fis-it-possible-with-scp-to-only-copy-files-that-match-a-certain-date%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            You can't do this directly with scp. The unix way is to combine tools, you want the find command.



            Here is an example of searching for a file with a given date:



            touch --date "2007-01-01" start
            touch --date "2008-01-01" end
            find -type f -newer start -not -newer end


            I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/



            To feed this into scp you could do this:



            find -type f -newer start -not -newer end -exec scp {} dest: ;


            This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:



            scp `find -type f -newer start -not -newer end` dest:





            share|improve this answer



















            • 1





              It's easy when you copy files from client to server, but what about the other way around?

              – Petr Peller
              Mar 30 '14 at 18:14






            • 2





              @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

              – Edward Betts
              Mar 31 '14 at 11:11


















            5














            You can't do this directly with scp. The unix way is to combine tools, you want the find command.



            Here is an example of searching for a file with a given date:



            touch --date "2007-01-01" start
            touch --date "2008-01-01" end
            find -type f -newer start -not -newer end


            I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/



            To feed this into scp you could do this:



            find -type f -newer start -not -newer end -exec scp {} dest: ;


            This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:



            scp `find -type f -newer start -not -newer end` dest:





            share|improve this answer



















            • 1





              It's easy when you copy files from client to server, but what about the other way around?

              – Petr Peller
              Mar 30 '14 at 18:14






            • 2





              @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

              – Edward Betts
              Mar 31 '14 at 11:11
















            5












            5








            5







            You can't do this directly with scp. The unix way is to combine tools, you want the find command.



            Here is an example of searching for a file with a given date:



            touch --date "2007-01-01" start
            touch --date "2008-01-01" end
            find -type f -newer start -not -newer end


            I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/



            To feed this into scp you could do this:



            find -type f -newer start -not -newer end -exec scp {} dest: ;


            This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:



            scp `find -type f -newer start -not -newer end` dest:





            share|improve this answer













            You can't do this directly with scp. The unix way is to combine tools, you want the find command.



            Here is an example of searching for a file with a given date:



            touch --date "2007-01-01" start
            touch --date "2008-01-01" end
            find -type f -newer start -not -newer end


            I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/



            To feed this into scp you could do this:



            find -type f -newer start -not -newer end -exec scp {} dest: ;


            This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:



            scp `find -type f -newer start -not -newer end` dest:






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 28 '13 at 16:46









            Edward BettsEdward Betts

            18614




            18614








            • 1





              It's easy when you copy files from client to server, but what about the other way around?

              – Petr Peller
              Mar 30 '14 at 18:14






            • 2





              @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

              – Edward Betts
              Mar 31 '14 at 11:11
















            • 1





              It's easy when you copy files from client to server, but what about the other way around?

              – Petr Peller
              Mar 30 '14 at 18:14






            • 2





              @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

              – Edward Betts
              Mar 31 '14 at 11:11










            1




            1





            It's easy when you copy files from client to server, but what about the other way around?

            – Petr Peller
            Mar 30 '14 at 18:14





            It's easy when you copy files from client to server, but what about the other way around?

            – Petr Peller
            Mar 30 '14 at 18:14




            2




            2





            @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

            – Edward Betts
            Mar 31 '14 at 11:11







            @PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` .

            – Edward Betts
            Mar 31 '14 at 11:11















            0














            An effective (one-line !) alternative (by @sudodus) is given here, which copies through an SSH channel using 'cpio' in copy-out mode. You can tailor the find arguments as you need, perhaps using the time/min/newer tests.



            To get your exact date & time test, create a dummy file with the correct time & date on your source system, use the find -newer test, or use the man page's -newerXY test. See https://linux.die.net/man/1/find



            The output of the find command running on the remote system is piped back to the local system securely via ssh, and saved.



            It appears to do all you require, but does not use 'scp' - which might affect your marking. But it does use a combination of Unix tools - which is the Unix approach !



            In any case, scp is a shortcut for the most common cases, this approach is more powerful, when filtering of files is required.



            ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )


            https://askubuntu.com/questions/1080590/how-to-use-find-in-scp-command






            share|improve this answer






























              0














              An effective (one-line !) alternative (by @sudodus) is given here, which copies through an SSH channel using 'cpio' in copy-out mode. You can tailor the find arguments as you need, perhaps using the time/min/newer tests.



              To get your exact date & time test, create a dummy file with the correct time & date on your source system, use the find -newer test, or use the man page's -newerXY test. See https://linux.die.net/man/1/find



              The output of the find command running on the remote system is piped back to the local system securely via ssh, and saved.



              It appears to do all you require, but does not use 'scp' - which might affect your marking. But it does use a combination of Unix tools - which is the Unix approach !



              In any case, scp is a shortcut for the most common cases, this approach is more powerful, when filtering of files is required.



              ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )


              https://askubuntu.com/questions/1080590/how-to-use-find-in-scp-command






              share|improve this answer




























                0












                0








                0







                An effective (one-line !) alternative (by @sudodus) is given here, which copies through an SSH channel using 'cpio' in copy-out mode. You can tailor the find arguments as you need, perhaps using the time/min/newer tests.



                To get your exact date & time test, create a dummy file with the correct time & date on your source system, use the find -newer test, or use the man page's -newerXY test. See https://linux.die.net/man/1/find



                The output of the find command running on the remote system is piped back to the local system securely via ssh, and saved.



                It appears to do all you require, but does not use 'scp' - which might affect your marking. But it does use a combination of Unix tools - which is the Unix approach !



                In any case, scp is a shortcut for the most common cases, this approach is more powerful, when filtering of files is required.



                ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )


                https://askubuntu.com/questions/1080590/how-to-use-find-in-scp-command






                share|improve this answer















                An effective (one-line !) alternative (by @sudodus) is given here, which copies through an SSH channel using 'cpio' in copy-out mode. You can tailor the find arguments as you need, perhaps using the time/min/newer tests.



                To get your exact date & time test, create a dummy file with the correct time & date on your source system, use the find -newer test, or use the man page's -newerXY test. See https://linux.die.net/man/1/find



                The output of the find command running on the remote system is piped back to the local system securely via ssh, and saved.



                It appears to do all you require, but does not use 'scp' - which might affect your marking. But it does use a combination of Unix tools - which is the Unix approach !



                In any case, scp is a shortcut for the most common cases, this approach is more powerful, when filtering of files is required.



                ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )


                https://askubuntu.com/questions/1080590/how-to-use-find-in-scp-command







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 5 at 15:25

























                answered Feb 5 at 15:13









                MikeWMikeW

                1335




                1335






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • 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%2fsuperuser.com%2fquestions%2f524974%2fis-it-possible-with-scp-to-only-copy-files-that-match-a-certain-date%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

                    Plaza Victoria

                    Puebla de Zaragoza

                    Musa