- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Scripting Help for find and replace
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:36 AM
08-29-2003 10:36 AM
I have a file with list of strings from which I will create http URL's.
I need to replace some special characters with URL encoding before I include them in the URL due to some limitations.
This is my requirement. I have file with following lines:
xxx.yyy++.zzz
aaa.bb+cc.ddd
I want to replace every "." with "%2E" and every "+" with %2B.
How do I do that in shell scripts ?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:41 AM
08-29-2003 10:41 AM
Re: Shell Scripting Help for find and replace
Praveen,
You can try this:
# sed 's/\./%2E/g' original_file | sed 's/+/%2B/g' > new_file
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:42 AM
08-29-2003 10:42 AM
Re: Shell Scripting Help for find and replace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:45 AM
08-29-2003 10:45 AM
Re: Shell Scripting Help for find and replace
VAR="xxx.yyy++.zzz"
sed -e 's/\./%2E/g' -e 's/+/%2B/g' $VAR
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:46 AM
08-29-2003 10:46 AM
Re: Shell Scripting Help for find and replace
VAR="xxx.yyy++.zzz"
echo $VAR | sed -e 's/\./%2E/g' -e 's/+/%2B/g'
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:48 AM
08-29-2003 10:48 AM
Re: Shell Scripting Help for find and replace
Note the backward quotes after the = and at the end. Do not include the input/output filenames.
This will execute what's in the back quotes and return the result. This value is then put into variable "newstring".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2003 10:48 AM
08-29-2003 10:48 AM
Re: Shell Scripting Help for find and replace
Note the backward quotes after the = and at the end. Do not include the input/output filenames.
This will execute what's in the back quotes and return the result. This value is then put into variable "newstring".
HTH
-- Rod Hills