- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- SED questions
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
02-14-2003 09:46 AM
02-14-2003 09:46 AM
In UNIX, using "sed", if I want to replace string 'cat' with string 'dog', it is -
sed -e 's/cat/dog'
But if I want to replace 'cat' with 'cat,newline char,dog,newline char' how do I do it ???
Any help is greatly appreciated and points will be given.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 09:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 10:09 AM
02-14-2003 10:09 AM
Re: SED questions
$ sed 's/cat/cat> dog> /g' test > newtest
That should replace all instances of "cat" with "cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 10:11 AM
02-14-2003 10:11 AM
Re: SED questions
$ sed 's/cat/cat\
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 10:16 AM
02-14-2003 10:16 AM
Re: SED questions
If you mean, literally. "replace 'cat' with 'cat,newline char,dog,newline char'", then:
# sed -e 's/cat/cat\^Jdog\^J/g'
...composing the ^J sequence (newline character) as I noted above.
Drop the 'g' flag if you want to do this only once per line.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2003 02:06 PM
02-17-2003 02:06 PM
Re: SED questions
I tried all of the above and could not get them to work from my hpux command line.
the closet I could come was with the following:
sed -e "s/cat/`echo "\rdog\r"`/g" test |tr "\r" "\n" >newtest
I hope you did better. I have a url that has all kinds of handy sed one liners:
http://www-h.eng.cam.ac.uk/help/tpl/unix/sed.html
none seemed to solve your problem.
Rory