LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux > 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
 
Thread Tools
Old 09-26-2005, 10:27 PM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora Core
Posts: 327
Thanked: 0
URL-Encoding on the command line?


[Log in to get rid of this advertisement]
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...
MikeyCarter is offline     Reply With Quote
Old 09-27-2005, 01:39 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 894
Thanked: 5
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.
CroMagnon is offline     Reply With Quote
Old 09-27-2005, 09:10 AM   #3
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora Core
Posts: 327
Thanked: 0

Original Poster
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.
MikeyCarter is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 07:48 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration