LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 09-26-2005, 10:27 PM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 450

Rep: Reputation: 31
URL-Encoding on the command line?


Does anyone one out there know of a linux command line tool which can URL-Encode (for lack of a better term) a string echo'd to it?

ie

echo "<b>This is some text</b>" | <some command>

and the output would be "&lt;b&gt;This is some...
 
Old 09-27-2005, 01:39 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
URL escaping would be like "www.fred.com/this file" => "www.fred.com/this%20file"

If you just want to replace known entities for HTML, you could use sed:
Code:
echo "<b>This is some text</b>" | sed "s/</\&lt;/g;s/>/\&gt;/g"
but obviously you need to extend it for whatever other entities you need to include (&amp;, &quot). If you just want to avoid finding all the entities, there's an awk script here that should do what you've described.
 
Old 09-27-2005, 09:10 AM   #3
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 450

Original Poster
Rep: Reputation: 31
I knew about that one. I was hoping for something that was already built. (That way I wouldn't have to plan for every variation)

In any case thanks for including that code.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla Linux Command Line URL Parsing Security Flaw Reported win32sux Linux - Security 9 10-06-2005 07:39 AM
command line mp3 encoding with freedb? chakkerz Linux - General 9 06-28-2004 08:08 PM
Fetching files via http (url) command line podollb Linux - Software 1 06-08-2004 06:01 PM
url encoding doesn't work fine with PHP markus1982 Programming 0 08-30-2003 03:04 AM
URL Encoding kud0ze Programming 2 12-11-2001 01:38 PM


All times are GMT -5. The time now is 02:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration