how to use scp to copy files and not overwrite files in the distination with same name












-1















I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine.I want to copy a file from a remote machine to my local machine. I am using scp. It was all good until I found out that I have another file in my local with the same name. I either have to change the name of the file in the source or in the destination every time I use scp. I want to avoid this overhead. Is there any hack to just copy the file with the name that we desire to? Like for example:



scp filename user@sysname:/path/ dest_filename









share|improve this question




















  • 2





    I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

    – tink
    Nov 19 '18 at 8:44











  • And no, scp can't do that. Use rsync or unison.

    – tink
    Nov 19 '18 at 8:46











  • I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

    – control-zed
    Nov 19 '18 at 9:28











  • You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

    – tink
    Nov 19 '18 at 16:31











  • rsync is doing the work thank you.

    – control-zed
    Nov 20 '18 at 8:57
















-1















I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine.I want to copy a file from a remote machine to my local machine. I am using scp. It was all good until I found out that I have another file in my local with the same name. I either have to change the name of the file in the source or in the destination every time I use scp. I want to avoid this overhead. Is there any hack to just copy the file with the name that we desire to? Like for example:



scp filename user@sysname:/path/ dest_filename









share|improve this question




















  • 2





    I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

    – tink
    Nov 19 '18 at 8:44











  • And no, scp can't do that. Use rsync or unison.

    – tink
    Nov 19 '18 at 8:46











  • I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

    – control-zed
    Nov 19 '18 at 9:28











  • You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

    – tink
    Nov 19 '18 at 16:31











  • rsync is doing the work thank you.

    – control-zed
    Nov 20 '18 at 8:57














-1












-1








-1








I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine.I want to copy a file from a remote machine to my local machine. I am using scp. It was all good until I found out that I have another file in my local with the same name. I either have to change the name of the file in the source or in the destination every time I use scp. I want to avoid this overhead. Is there any hack to just copy the file with the name that we desire to? Like for example:



scp filename user@sysname:/path/ dest_filename









share|improve this question
















I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine.I want to copy a file from a remote machine to my local machine. I am using scp. It was all good until I found out that I have another file in my local with the same name. I either have to change the name of the file in the source or in the destination every time I use scp. I want to avoid this overhead. Is there any hack to just copy the file with the name that we desire to? Like for example:



scp filename user@sysname:/path/ dest_filename






linux file scp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 9:04







control-zed

















asked Nov 19 '18 at 8:39









control-zedcontrol-zed

137




137








  • 2





    I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

    – tink
    Nov 19 '18 at 8:44











  • And no, scp can't do that. Use rsync or unison.

    – tink
    Nov 19 '18 at 8:46











  • I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

    – control-zed
    Nov 19 '18 at 9:28











  • You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

    – tink
    Nov 19 '18 at 16:31











  • rsync is doing the work thank you.

    – control-zed
    Nov 20 '18 at 8:57














  • 2





    I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

    – tink
    Nov 19 '18 at 8:44











  • And no, scp can't do that. Use rsync or unison.

    – tink
    Nov 19 '18 at 8:46











  • I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

    – control-zed
    Nov 19 '18 at 9:28











  • You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

    – tink
    Nov 19 '18 at 16:31











  • rsync is doing the work thank you.

    – control-zed
    Nov 20 '18 at 8:57








2




2





I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

– tink
Nov 19 '18 at 8:44





I'm voting to close this question as off-topic because it has nothing to do with programming and would be better suited at superuser.com/questions/tagged/linux

– tink
Nov 19 '18 at 8:44













And no, scp can't do that. Use rsync or unison.

– tink
Nov 19 '18 at 8:46





And no, scp can't do that. Use rsync or unison.

– tink
Nov 19 '18 at 8:46













I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

– control-zed
Nov 19 '18 at 9:28





I am writing an automated test script that will copy the files from the remote location and make changes to it before copying them to another remotely connected machine. How is this not related to programming? I'm sorry I don't understand. Please explain yourself.

– control-zed
Nov 19 '18 at 9:28













You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

– tink
Nov 19 '18 at 16:31





You didn't mention any of that. And I stand by my suggestion to use rsync to avoid the overwriting.

– tink
Nov 19 '18 at 16:31













rsync is doing the work thank you.

– control-zed
Nov 20 '18 at 8:57





rsync is doing the work thank you.

– control-zed
Nov 20 '18 at 8:57












1 Answer
1






active

oldest

votes


















0














Based off of: https://en.wikipedia.org/wiki/Secure_copy#Function



scp user@host:directory/SourceFile TargetFile


Would copy the "SourceFile", say, from remote, to the local path "TargetFile".



So you could in theory do:



scp bob@remotecomputer:directory/LogonTime.txt /somelocalpath/LogonTime20181119.txt





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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%2fstackoverflow.com%2fquestions%2f53370969%2fhow-to-use-scp-to-copy-files-and-not-overwrite-files-in-the-distination-with-sam%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Based off of: https://en.wikipedia.org/wiki/Secure_copy#Function



    scp user@host:directory/SourceFile TargetFile


    Would copy the "SourceFile", say, from remote, to the local path "TargetFile".



    So you could in theory do:



    scp bob@remotecomputer:directory/LogonTime.txt /somelocalpath/LogonTime20181119.txt





    share|improve this answer




























      0














      Based off of: https://en.wikipedia.org/wiki/Secure_copy#Function



      scp user@host:directory/SourceFile TargetFile


      Would copy the "SourceFile", say, from remote, to the local path "TargetFile".



      So you could in theory do:



      scp bob@remotecomputer:directory/LogonTime.txt /somelocalpath/LogonTime20181119.txt





      share|improve this answer


























        0












        0








        0







        Based off of: https://en.wikipedia.org/wiki/Secure_copy#Function



        scp user@host:directory/SourceFile TargetFile


        Would copy the "SourceFile", say, from remote, to the local path "TargetFile".



        So you could in theory do:



        scp bob@remotecomputer:directory/LogonTime.txt /somelocalpath/LogonTime20181119.txt





        share|improve this answer













        Based off of: https://en.wikipedia.org/wiki/Secure_copy#Function



        scp user@host:directory/SourceFile TargetFile


        Would copy the "SourceFile", say, from remote, to the local path "TargetFile".



        So you could in theory do:



        scp bob@remotecomputer:directory/LogonTime.txt /somelocalpath/LogonTime20181119.txt






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 8:46









        user3012708user3012708

        271313




        271313
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f53370969%2fhow-to-use-scp-to-copy-files-and-not-overwrite-files-in-the-distination-with-sam%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







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini