- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed command to replace string
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
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
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:[email protected]
WSS_81_err.mail:[email protected]
WSS_82_err.mail:[email protected]
WSS_83_err.mail:[email protected]
WSS_ERR_80.mail:[email protected]
WSS_ERR_81.mail:[email protected]
WSS_ERR_82.mail:[email protected]
WSS_ERR_83.mail:[email protected]
Now I wish to replace in *.* wherever [email protected] is available with ' '. Could below command work fine or let me know the correct command:
sed -n 's/[email protected]//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 [email protected] and/or [email protected] 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:[email protected]
WSS_81_err.mail:[email protected]
WSS_82_err.mail:[email protected]
WSS_83_err.mail:[email protected]
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 [email protected] with *.*
Then use this.
cat filename | sed 's/[email protected]/*.*/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 [email protected] also :-(
Please advise...consider i have fix one i.e. [email protected]
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