urlencode

(Command too long..See sample Output..)
curl doesn't provide url-encoding for 'GET' data, it have an option '--data-urlencode', but its only for 'POST' data. Thats why I need to write down this commandline. With 'perl', 'php' and 'python', this is one liner, but just I wrote it for fun. Works in Ubuntu, will work in all linux varients(I hope it will work in unix varients also).
Sample Output
$ sed -e's/./&\n/g' -e's/ /%20/g' | grep -v '^$' | while read CHAR; do test "${CHAR}" = "%20" && echo "${CHAR}" || echo "${CHAR}" | grep -E '[-[:alnum:]!*.'"'"'()]|\[|\]' || echo -n "${CHAR}" | od -t x1 | tr ' ' '\n' | grep '^[[:alnum:]]\{2\}$' | tr '[a-z]' '[A-Z]' | sed -e's/^/%/g'; done | sed -e's/%20/+/g' | tr -d '\n'; echo
http://www.google.com
http%3A%2F%2Fwww.google.com
$

-3
By: mohan43u
2009-06-14 20:34:37

What Others Think

The nature of the topic seems really technical and in case you have any idea what this was all about then coursework writing help can be of a great source of help for all of us so we would be able to get to know so much more now.
jamwak5 · 39 weeks and 5 days ago
The first phase the preparation should, theoretically, be uninfluenced by the intended intensity and duration of the sound which is subsequently produced. In fact, however, so quickly are the three phases accomplished that the pianist rarely has capacity to think, in performance, of each phase separately. Valentine week 2021
KayGasaway · 35 weeks and 6 days ago
Great Content. Happy New Year 2021 Is ahead and if you are planing for the best to make your new year 2021 more speical then you can get ideas from below links http://happynewyearduck.com/">Happy New Year 2021 http://happynewyearimagespics.com/">Happy New Year 2021 Images http://quotesforhappynewyear.com/">Quotes For Happy New Year 2021 Flocked Christmas Tree 2020
addamjohns · 32 weeks and 3 days ago
Free slots and free slots online games selected by professionals! Find the best payout casino358, free bonus online casino, and best real money slots games!
GeorgeMGleason · 29 weeks and 5 days ago
If Your Love your articles Tthanks for sharing. Also check Happy Chocolate Day 2021. https://happyvalentinesday2021.net/
framcheema · 25 weeks and 5 days ago
[url="https://happyvalentinesday2021.net"]happy chocolate day 2021[/url] is the best way to have a good day.
framcheema · 25 weeks and 5 days ago
happy chocolate day 2021
framcheema · 25 weeks and 5 days ago
Good technical information. It saves me a lot of time by using commands instead of doing the complete task. You can gain cool skills.Go to citizenship by investment dubai .Thanks for sharing this cool info.
DeVereGroup · 20 weeks and 1 day ago
Thanks for the post Best regards HowardDLaporte
HowardDLaporte · 16 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: