Filenames with spaces inside perl command inside echo

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











up vote
2
down vote

favorite












How do I support filenames with spaces in the following command?



echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=<F>; close F; print MIME::Base64::encode(join(q, @lines))' $filename)"


I tried the following which didn't seem to work:



  1. echo ... "$filename")

  2. echo '$(... "open..." "$filename")'

  3. echo $(...'open ... "$filename")






share|improve this question
























    up vote
    2
    down vote

    favorite












    How do I support filenames with spaces in the following command?



    echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=<F>; close F; print MIME::Base64::encode(join(q, @lines))' $filename)"


    I tried the following which didn't seem to work:



    1. echo ... "$filename")

    2. echo '$(... "open..." "$filename")'

    3. echo $(...'open ... "$filename")






    share|improve this question






















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      How do I support filenames with spaces in the following command?



      echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=<F>; close F; print MIME::Base64::encode(join(q, @lines))' $filename)"


      I tried the following which didn't seem to work:



      1. echo ... "$filename")

      2. echo '$(... "open..." "$filename")'

      3. echo $(...'open ... "$filename")






      share|improve this question












      How do I support filenames with spaces in the following command?



      echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=<F>; close F; print MIME::Base64::encode(join(q, @lines))' $filename)"


      I tried the following which didn't seem to work:



      1. echo ... "$filename")

      2. echo '$(... "open..." "$filename")'

      3. echo $(...'open ... "$filename")








      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 26 at 12:39









      forthrin

      832921




      832921




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          echo "$(perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename")"


          I assume echo is an example here. If not, this:



          perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename"


          would be equivalent.



          Note that some systems have a base64 command:



          base64 < "$filename"


          Or if openssl is installed:



          openssl base64 < "$filename"





          share|improve this answer




















          • Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
            – forthrin
            Aug 26 at 13:50










          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%2f464915%2ffilenames-with-spaces-inside-perl-command-inside-echo%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
          4
          down vote



          accepted










          echo "$(perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename")"


          I assume echo is an example here. If not, this:



          perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename"


          would be equivalent.



          Note that some systems have a base64 command:



          base64 < "$filename"


          Or if openssl is installed:



          openssl base64 < "$filename"





          share|improve this answer




















          • Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
            – forthrin
            Aug 26 at 13:50














          up vote
          4
          down vote



          accepted










          echo "$(perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename")"


          I assume echo is an example here. If not, this:



          perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename"


          would be equivalent.



          Note that some systems have a base64 command:



          base64 < "$filename"


          Or if openssl is installed:



          openssl base64 < "$filename"





          share|improve this answer




















          • Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
            – forthrin
            Aug 26 at 13:50












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          echo "$(perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename")"


          I assume echo is an example here. If not, this:



          perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename"


          would be equivalent.



          Note that some systems have a base64 command:



          base64 < "$filename"


          Or if openssl is installed:



          openssl base64 < "$filename"





          share|improve this answer












          echo "$(perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename")"


          I assume echo is an example here. If not, this:



          perl -MMIME::Base64 -0777 -pe '$_=MIME::Base64::encode$_' < "$filename"


          would be equivalent.



          Note that some systems have a base64 command:



          base64 < "$filename"


          Or if openssl is installed:



          openssl base64 < "$filename"






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 26 at 13:00









          Stéphane Chazelas

          283k53521854




          283k53521854











          • Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
            – forthrin
            Aug 26 at 13:50
















          • Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
            – forthrin
            Aug 26 at 13:50















          Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
          – forthrin
          Aug 26 at 13:50




          Brilliant response! Not only did you solve the problem, but provided several simple ways to achieve the same thing, all of which work. Actually echo was part of the original code, but I found it to be unnecessary after all. PS! Since this is going into an email, one should do base64 -b 76.
          – forthrin
          Aug 26 at 13:50

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464915%2ffilenames-with-spaces-inside-perl-command-inside-echo%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery