- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sed command-- Need help
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
Discussions
Discussions
Forums
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
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
тАО03-24-2009 07:18 PM
тАО03-24-2009 07:18 PM
I have a quite few no. of scripts in a directory /Scripts. In every Script in the DIR, I want to replace the text OS with Cargos.
One of the sample script is ....
if [ $ERR -gt 0 ]
then
#Object failed
/opt/OV/bin/OpC/opcmsg application=Monitor severity=critical object=OS msg
_text="$0: Object failed" msg_grp=GEC node=test.sample.com
fi
else
# Second Object failed
/opt/OV/bin/OpC/opcmsg application=Monitor severity=critical object=OS msg_t
ext="$0: Second Object failed" msg_grp=GEC node=test.sample.com
fi
I intent to change object=OS to object=Cargos
After going through man pages of sed, I issued command,
sed 's/OS/Corgos/g' sample.sh
still Object remains OS.
Any Idea, where I'm doing mistake?
Regards,
Nagu
Solved! Go to Solution.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 08:02 PM
тАО03-24-2009 08:02 PM
Re: Sed command-- Need help
sed 's/OS/Corgos/g' sample.sh > sample.sh.new
Then move it back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 08:06 PM
тАО03-24-2009 08:06 PM
Re: Sed command-- Need help
Is there any way so that I can avoild moving files??
May not be with sed, if it doesnt support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 08:19 PM
тАО03-24-2009 08:19 PM
Re: Sed command-- Need help
You can open your file into vi
vi sample.sh
press Esc, then press : type below string
:1,$s/OS/Corgos/gp press enter
it will change your OS string into Corgos
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 09:06 PM
тАО03-24-2009 09:06 PM
SolutionYou can use ex(1) instead. See this other thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1322777
ex <
wq
EOF
- Tags:
- ex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 09:20 PM
тАО03-24-2009 09:20 PM
Re: Sed command-- Need help
Your suggestion helped me to meet my requirement of changing the stuff in over 100+ scripts.
Thanks a lot
Regards,
Nagu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 09:54 AM
тАО04-03-2009 09:54 AM
Re: Sed command-- Need help
perl -pi -e 's/OS/Corgos/g' sample.sh
with sed you have to re-direct output to a 2nd file.. > 2ndfilename.ext
- Tags:
- Perl