Can not echo entire line to file

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








up vote
1
down vote

favorite












I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.



echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh


When I run the script below this, I get



andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.

#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"






share|improve this question

















  • 1




    Which part makes it into the file? Please edit the question to clarify.
    – wjandrea
    Jun 11 at 21:16







  • 1




    Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
    – wjandrea
    Jun 12 at 1:21















up vote
1
down vote

favorite












I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.



echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh


When I run the script below this, I get



andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.

#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"






share|improve this question

















  • 1




    Which part makes it into the file? Please edit the question to clarify.
    – wjandrea
    Jun 11 at 21:16







  • 1




    Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
    – wjandrea
    Jun 12 at 1:21













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.



echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh


When I run the script below this, I get



andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.

#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"






share|improve this question













I can not figure out how to get the following line echoed to a file.
Only part of it makes it into the file.



echo perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);">>Show_Percent_Reserved_Blocks.sh


When I run the script below this, I get



andyk_~/Downloads$ Show_Percent_Reserved_Blocks.sh
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 2: Block: command not found
/home/andy/bin/Show_Percent_Reserved_Blocks.sh: line 3: Reserved: command not found
syntax error at -e line 1, near "/ )"
Execution of -e aborted due to compilation errors.

#!/bin/bash
Block count: 421958912
Reserved block count: 4219589
perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"








share|improve this question












share|improve this question




share|improve this question








edited Jun 11 at 21:59









dadexix86

5,3622492




5,3622492









asked Jun 11 at 21:03









fixit7

435316




435316







  • 1




    Which part makes it into the file? Please edit the question to clarify.
    – wjandrea
    Jun 11 at 21:16







  • 1




    Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
    – wjandrea
    Jun 12 at 1:21













  • 1




    Which part makes it into the file? Please edit the question to clarify.
    – wjandrea
    Jun 11 at 21:16







  • 1




    Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
    – wjandrea
    Jun 12 at 1:21








1




1




Which part makes it into the file? Please edit the question to clarify.
– wjandrea
Jun 11 at 21:16





Which part makes it into the file? Please edit the question to clarify.
– wjandrea
Jun 11 at 21:16





1




1




Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
– wjandrea
Jun 12 at 1:21





Your edits seem to be about different issues, namely that you've got two non-command lines in the file, and a syntax error in the Perl command. Please ask new question, and make sure to clarify what you're expecting to happen.
– wjandrea
Jun 12 at 1:21











1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










The problem is that as you've used double quotes, the variable references ($reserved_block_count, $block_count) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:



echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh





share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1045727%2fcan-not-echo-entire-line-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
    5
    down vote



    accepted










    The problem is that as you've used double quotes, the variable references ($reserved_block_count, $block_count) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:



    echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh





    share|improve this answer

























      up vote
      5
      down vote



      accepted










      The problem is that as you've used double quotes, the variable references ($reserved_block_count, $block_count) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:



      echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh





      share|improve this answer























        up vote
        5
        down vote



        accepted







        up vote
        5
        down vote



        accepted






        The problem is that as you've used double quotes, the variable references ($reserved_block_count, $block_count) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:



        echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh





        share|improve this answer













        The problem is that as you've used double quotes, the variable references ($reserved_block_count, $block_count) are being expanded in the current (invoking) shell environment; you need to quote the whole thing with single quotes around:



        echo 'perl -e "printf("%.1lf%%n", ($reserved_block_count * 100.0 ) / $block_count);"' >>Show_Percent_Reserved_Blocks.sh






        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 11 at 21:07









        heemayl

        63.5k8126202




        63.5k8126202






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1045727%2fcan-not-echo-entire-line-to-file%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error