2018年7月14日土曜日

シェルで urlencode したいとき


最近は、どのOSにも python が入っているので、python を使用します。

function urlencode
{
    echo "$1" \
        | python -c 'import sys,urllib; sys.stdout.write(urllib.quote_plus(raw_input()))'
}

urlencode "xxxxx"