greycat 1237996799 learn http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248327751 forget lhunath 1248327763 learn # urlencode() { while read -n 1 c; do [[ $c = [a-zA-Z-_.~] ]] && printf %s "$c" || printf %%%x "'$c" || echo -n "$c"; done; <<< "$1" }; urlencode "The Bars - Foo.mp3" # or see http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248327852 forget lhunath 1248327869 learn # urlencode() { while read -n 1 c; do [[ $c = [a-zA-Z-_.~] ]] && printf %s "$c" || printf %%%x "'$c"; done; <<< "$1" }; urlencode "The Bars - Foo.mp3" # or see http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248327956 forget lhunath 1248327971 learn # urlencode() { while read -n 1 c; do [[ $c = [a-zA-Z-_.~] ]] && printf %s "$c" || printf %%%x "'$c"; done; <<< "$1"; }; urlencode "The Bars - Foo.mp3" # or see http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248328039 forget lhunath 1248328052 learn # urlencode() { while read -n 1 c; do [[ $c = [a-zA-Z-_.~] ]] && printf %s "$c" || printf %%%x "'$c"; done <<< "$1"; }; urlencode "The Bars - Foo.mp3" # or see http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248328090 forget lhunath 1248328101 learn # urlencode() { while read -n 1 c; do [[ $c = [0-9a-zA-Z-_.~] ]] && printf %s "$c" || printf %%%x "'$c"; done <<< "$1"; }; urlencode "The Bars - Foo.mp3" # or see http://bash.projectnet.org/wiki/index.php/Urlencode lhunath 1248328210 forget lhunath 1248328219 learn http://bash.projectnet.org/wiki/index.php/Urlencode neurolysis 1314048615 forget neurolysis 1314048619 learn https://gist.github.com/1163649 neurolysis 1316793819 forget neurolysis 1316793819 learn https://raw.github.com/cdown/bash-snippets/master/urlencode pgas 1332850230 forget cdown 1345155748 learn https://gist.github.com/1163649 geirha 1438249882 forget geirha 1438249891 learn https://gist.github.com/887e74e74877c7613920 greycat 1540494083 forget greycat 1540494084 learn See http://mywiki.wooledge.org/BashFAQ/071 or https://gist.github.com/887e74e74877c7613920