echo full command to file

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











up vote
0
down vote

favorite












I have the following command



echo “more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST” >> NOTNY.sh && chmod 0777 NOTNY.sh 


However when I run the command and view the content of NOTNY.sh it contains



“more PHONEBOOK.lst


It should contain



more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST


How do I copy the text from the command and not the result I am getting?







share|improve this question
















  • 4




    I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
    – Jeff Schaller
    Oct 15 '17 at 22:03










  • How do I make it see the command as a whole and not evaluate the command?
    – John Hamlett IV
    Oct 15 '17 at 22:11






  • 2




    Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
    – AlexP
    Oct 15 '17 at 23:11














up vote
0
down vote

favorite












I have the following command



echo “more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST” >> NOTNY.sh && chmod 0777 NOTNY.sh 


However when I run the command and view the content of NOTNY.sh it contains



“more PHONEBOOK.lst


It should contain



more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST


How do I copy the text from the command and not the result I am getting?







share|improve this question
















  • 4




    I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
    – Jeff Schaller
    Oct 15 '17 at 22:03










  • How do I make it see the command as a whole and not evaluate the command?
    – John Hamlett IV
    Oct 15 '17 at 22:11






  • 2




    Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
    – AlexP
    Oct 15 '17 at 23:11












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have the following command



echo “more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST” >> NOTNY.sh && chmod 0777 NOTNY.sh 


However when I run the command and view the content of NOTNY.sh it contains



“more PHONEBOOK.lst


It should contain



more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST


How do I copy the text from the command and not the result I am getting?







share|improve this question












I have the following command



echo “more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST” >> NOTNY.sh && chmod 0777 NOTNY.sh 


However when I run the command and view the content of NOTNY.sh it contains



“more PHONEBOOK.lst


It should contain



more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST


How do I copy the text from the command and not the result I am getting?









share|improve this question











share|improve this question




share|improve this question










asked Oct 15 '17 at 21:49









John Hamlett IV

11




11







  • 4




    I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
    – Jeff Schaller
    Oct 15 '17 at 22:03










  • How do I make it see the command as a whole and not evaluate the command?
    – John Hamlett IV
    Oct 15 '17 at 22:11






  • 2




    Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
    – AlexP
    Oct 15 '17 at 23:11












  • 4




    I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
    – Jeff Schaller
    Oct 15 '17 at 22:03










  • How do I make it see the command as a whole and not evaluate the command?
    – John Hamlett IV
    Oct 15 '17 at 22:11






  • 2




    Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
    – AlexP
    Oct 15 '17 at 23:11







4




4




I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
– Jeff Schaller
Oct 15 '17 at 22:03




I'm guessing those are "smart" quotes, which your shell saw as just more bytes instead of actual quotes.
– Jeff Schaller
Oct 15 '17 at 22:03












How do I make it see the command as a whole and not evaluate the command?
– John Hamlett IV
Oct 15 '17 at 22:11




How do I make it see the command as a whole and not evaluate the command?
– John Hamlett IV
Oct 15 '17 at 22:11




2




2




Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
– AlexP
Oct 15 '17 at 23:11




Quote the string. Your example contains the characters “ and ” (U+201C and U+201D) which are not quotes as far as the shell is concerned. The shell understands ' (U+0027) and " (U+0022). The fancy curly characters featured in your example are just ordinary fancy curly characters.
– AlexP
Oct 15 '17 at 23:11










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Instead of “smart” quotes, use normal "double-quotes":



printf "%sn" "more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


Or, saving a pointless call to more, since awk will read the files you tell it to:



printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


Or, since the second sort will just override the first one:



printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 





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: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f398290%2fecho-full-command-to-file%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
    1
    down vote













    Instead of “smart” quotes, use normal "double-quotes":



    printf "%sn" "more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


    Or, saving a pointless call to more, since awk will read the files you tell it to:



    printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


    Or, since the second sort will just override the first one:



    printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 





    share|improve this answer


























      up vote
      1
      down vote













      Instead of “smart” quotes, use normal "double-quotes":



      printf "%sn" "more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


      Or, saving a pointless call to more, since awk will read the files you tell it to:



      printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


      Or, since the second sort will just override the first one:



      printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 





      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        Instead of “smart” quotes, use normal "double-quotes":



        printf "%sn" "more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


        Or, saving a pointless call to more, since awk will read the files you tell it to:



        printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


        Or, since the second sort will just override the first one:



        printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 





        share|improve this answer














        Instead of “smart” quotes, use normal "double-quotes":



        printf "%sn" "more PHONEBOOK.lst | awk '!/ NY /' | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


        Or, saving a pointless call to more, since awk will read the files you tell it to:



        printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k1 | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 


        Or, since the second sort will just override the first one:



        printf "%sn" "awk '!/ NY /' PHONEBOOK.lst | sort -k4 | tee PHONENOTNY.LST" >> NOTNY.sh && chmod 0777 NOTNY.sh 






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 16 '17 at 21:49

























        answered Oct 15 '17 at 23:17









        Jeff Schaller

        32.1k849109




        32.1k849109



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398290%2fecho-full-command-to-file%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?

            Christian Cage

            How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?