Filenames with spaces inside perl command inside echo

Filenames with spaces inside perl command inside echo



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:


echo ... "$filename")


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


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




1 Answer
1


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



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


echo


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



would be equivalent.



Note that some systems have a base64 command:


base64


base64 < "$filename"



Or if openssl is installed:


openssl


openssl base64 < "$filename"





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


base64 -b 76






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ