How to create a executable file(.sh) in linux that will copy and paste file










-4














How to create a .sh file that will copy and paste files?



I created a script.sh file with the following code:



#!/bin/sh
tar -pzvxf file1.tar (to unzip)
cp -a /root/Desktop/file1/. /root/Desktop/Destination (copy)


After which I ./script.sh to run it but it wouldn't run.
Any idea why?










share|improve this question























  • About all languages can do that.
    – Jean-Marc Zimmer
    Nov 13 '18 at 7:28










  • What about in linux? Can u show an example?
    – Jayh
    Nov 13 '18 at 8:17










  • Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
    – Jean-Marc Zimmer
    Nov 13 '18 at 8:56











  • I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
    – Jayh
    Nov 13 '18 at 9:27










  • Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
    – Jean-Marc Zimmer
    Nov 13 '18 at 9:43















-4














How to create a .sh file that will copy and paste files?



I created a script.sh file with the following code:



#!/bin/sh
tar -pzvxf file1.tar (to unzip)
cp -a /root/Desktop/file1/. /root/Desktop/Destination (copy)


After which I ./script.sh to run it but it wouldn't run.
Any idea why?










share|improve this question























  • About all languages can do that.
    – Jean-Marc Zimmer
    Nov 13 '18 at 7:28










  • What about in linux? Can u show an example?
    – Jayh
    Nov 13 '18 at 8:17










  • Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
    – Jean-Marc Zimmer
    Nov 13 '18 at 8:56











  • I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
    – Jayh
    Nov 13 '18 at 9:27










  • Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
    – Jean-Marc Zimmer
    Nov 13 '18 at 9:43













-4












-4








-4







How to create a .sh file that will copy and paste files?



I created a script.sh file with the following code:



#!/bin/sh
tar -pzvxf file1.tar (to unzip)
cp -a /root/Desktop/file1/. /root/Desktop/Destination (copy)


After which I ./script.sh to run it but it wouldn't run.
Any idea why?










share|improve this question















How to create a .sh file that will copy and paste files?



I created a script.sh file with the following code:



#!/bin/sh
tar -pzvxf file1.tar (to unzip)
cp -a /root/Desktop/file1/. /root/Desktop/Destination (copy)


After which I ./script.sh to run it but it wouldn't run.
Any idea why?







linux sh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 3:26









Robert

2,15062535




2,15062535










asked Nov 13 '18 at 7:26









JayhJayh

11




11











  • About all languages can do that.
    – Jean-Marc Zimmer
    Nov 13 '18 at 7:28










  • What about in linux? Can u show an example?
    – Jayh
    Nov 13 '18 at 8:17










  • Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
    – Jean-Marc Zimmer
    Nov 13 '18 at 8:56











  • I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
    – Jayh
    Nov 13 '18 at 9:27










  • Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
    – Jean-Marc Zimmer
    Nov 13 '18 at 9:43
















  • About all languages can do that.
    – Jean-Marc Zimmer
    Nov 13 '18 at 7:28










  • What about in linux? Can u show an example?
    – Jayh
    Nov 13 '18 at 8:17










  • Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
    – Jean-Marc Zimmer
    Nov 13 '18 at 8:56











  • I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
    – Jayh
    Nov 13 '18 at 9:27










  • Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
    – Jean-Marc Zimmer
    Nov 13 '18 at 9:43















About all languages can do that.
– Jean-Marc Zimmer
Nov 13 '18 at 7:28




About all languages can do that.
– Jean-Marc Zimmer
Nov 13 '18 at 7:28












What about in linux? Can u show an example?
– Jayh
Nov 13 '18 at 8:17




What about in linux? Can u show an example?
– Jayh
Nov 13 '18 at 8:17












Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
– Jean-Marc Zimmer
Nov 13 '18 at 8:56





Do you even know what an executable file is ? -I mean, have you ever tried opening one in your editor ? An executable is a binary file. You can't edit it directly, you have to use another language to create it. C, C++, Python, Java, R, Perl, PHP, Even JavaScript can do this. Please read the help center
– Jean-Marc Zimmer
Nov 13 '18 at 8:56













I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
– Jayh
Nov 13 '18 at 9:27




I tried editing the bat file move "folder" "D:destination" only those file in the folder is copied but those other folders in the folder is not copied. Any idea why?
– Jayh
Nov 13 '18 at 9:27












Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
– Jean-Marc Zimmer
Nov 13 '18 at 9:43




Edit your post by adding : what you already tried, what you got, what you want to do, add the corresponding tags
– Jean-Marc Zimmer
Nov 13 '18 at 9:43












1 Answer
1






active

oldest

votes


















0














Ensure that the script has it's executable bit set.
Try using this in your shell.



chmod +x ./script.sh


This will ensure that the script can be executed by your shell.






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%2f53275874%2fhow-to-create-a-executable-file-sh-in-linux-that-will-copy-and-paste-file%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














    Ensure that the script has it's executable bit set.
    Try using this in your shell.



    chmod +x ./script.sh


    This will ensure that the script can be executed by your shell.






    share|improve this answer

























      0














      Ensure that the script has it's executable bit set.
      Try using this in your shell.



      chmod +x ./script.sh


      This will ensure that the script can be executed by your shell.






      share|improve this answer























        0












        0








        0






        Ensure that the script has it's executable bit set.
        Try using this in your shell.



        chmod +x ./script.sh


        This will ensure that the script can be executed by your shell.






        share|improve this answer












        Ensure that the script has it's executable bit set.
        Try using this in your shell.



        chmod +x ./script.sh


        This will ensure that the script can be executed by your shell.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 3:50









        ajxsajxs

        833514




        833514



























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53275874%2fhow-to-create-a-executable-file-sh-in-linux-that-will-copy-and-paste-file%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

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党