Skip to content

Instantly share code, notes, and snippets.

@jjarmoc
Created January 6, 2012 17:21
Show Gist options
  • Save jjarmoc/1571540 to your computer and use it in GitHub Desktop.
Save jjarmoc/1571540 to your computer and use it in GitHub Desktop.
Quoted Printable encode/decode bash aliases - suitable for pipelining
# To decode:
# qp -d string
# To encode:
# qp string
alias qpd='perl -MMIME::QuotedPrint -pe '\''$_=MIME::QuotedPrint::decode($_);'\'''
alias qpe='perl -MMIME::QuotedPrint -pe '\''$_=MIME::QuotedPrint::encode($_);'\'''
function qp {
if [[ "$1" = "-d" ]]
then
echo ${@:2} | qpd
else
echo ${@} | qpe
fi
}
@AloisMahdal
Copy link

@Hubro: this should be the accepted answer!

(oh wait, I'm not on stackoverflow?)

@eiro
Copy link

eiro commented Apr 26, 2019

the perl version can be much simple:

qp () {
    perl -MMIME::QuotedPrint -s -ne '
        BEGIN { *e = $d ? \&decode_qp : \&encode_qp }
        print e $_
    ' -- "$@"
}

qp /etc/hostname - /etc/hostname <<< ∀✓ | qp -d

@l0b0
Copy link

l0b0 commented Jul 4, 2023

qprint --decode and qprint --encode are easy to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment