- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed command to replace string
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
06-06-2006 07:21 PM
06-06-2006 07:21 PM
I grepped certain pattern and got below results:
WSS_80_err.mail:xyz@abb.com
WSS_81_err.mail:xyz@abb.com
WSS_82_err.mail:xyz@abb.com
WSS_83_err.mail:xyz@abb.com
WSS_ERR_80.mail:xyz@abb.com
WSS_ERR_81.mail:xyz@abb.com
WSS_ERR_82.mail:xyz@abb.com
WSS_ERR_83.mail:xyz@abb.com
Now I wish to replace in *.* wherever xyz@abb.com is available with ' '. Could below command work fine or let me know the correct command:
sed -n 's/xyz@abb.com//g' *.*
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 07:47 PM
06-06-2006 07:47 PM
Solution# sed 's/foo/bar/' < file > tmp
# mv tmp file
In a loop that can be done like
# for i in *.* ; do
> sed 's/foo/bar/' < $i > __$i.tmp_
> mv __$i.tmp_ $i
> done
Or use perl instead, which *can* do in-file replacements
# perl -pi -e's/foo/bar/' *.*
in your case
# perl -pi -e's/\bxyz\@abb.com\b//g' *.*
Note that I made the pattern more safe by adding two \b (word bound) assertions, so zxyz@abb.com and/or xyz@abb.common will not match.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 08:05 PM
06-06-2006 08:05 PM
Re: sed command to replace string
Did you mean that if you had
WSS_80_err.mail:xyz@abb.com
WSS_81_err.mail:xyz@abb.com
WSS_82_err.mail:xyz@abb.com
WSS_83_err.mail:xyz@abb.com
you wanted it to be as
WSS_80_err.mail:*.*
WSS_81_err.mail:*.*
WSS_82_err.mail:*.*
WSS_83_err.mail:*.*
WSS_ERR_80.mail:*.*
i.e. replace xyz@abb.com with *.*
Then use this.
cat filename | sed 's/xyz@abb.com/*.*/g'
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 08:05 PM
06-06-2006 08:05 PM
Re: sed command to replace string
# perl -pi -e's/\bxyz\@abb.com\b//g' *.*
But it has replaced x_yz@abb.com also :-(
Please advise...consider i have fix one i.e. xyz.abc@abb.com
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 09:46 PM
06-06-2006 09:46 PM