- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help me in shell scripting
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
10-02-2006 07:57 PM
10-02-2006 07:57 PM
I want to grep a pattern in my file and want to replace it with a new one.
Here is the line where i need to modify
multimediaGroup type="media" dbid="525"
I want to replace the dbid value from 525 to 635 and how can i able to do it.
How can I write a script to read my file and grep the pattern 525 and get new input from me as 635 , then make it as modification .So finally I need that my file should have the entry as follows..
multimediaGroup type="media" dbid="635"
AnyBody well in scripting can help me..
Thanks & regards
Suseendran .A
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 08:06 PM
10-02-2006 08:06 PM
Re: Help me in shell scripting
how about:
sed "1,$ s/525/635/g" input.dat > output.dat
Please note, this replace ALL occurances of 525 with 635.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 08:13 PM
10-02-2006 08:13 PM
Re: Help me in shell scripting
It want to tale bid number as a reference and to replace the ID value..
I got a Solution for the above by the following script
sed -e 's/multimediaGroup type="media" dbid="525"/multimediaGroup type="media" dbid="635"/' file >/tmp/tmpfile.$$
Thanks for the help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2006 12:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2006 12:22 AM
10-03-2006 12:22 AM
Re: Help me in shell scripting
perl -pli -e '/(multimediaGroup type="media" dbid=)"525"/\1"635"/g' ${file}
should do the trick. It'll update the file(s) in place so no need to move temporary files back into place.
One thing I will usually do is skip the i argument for the first run:
perl -pl -e '/(multimediaGroup type="media" dbid=)"525"/\1"635"/g' ${file} | grep 635
to verify *ONLY* the lines you're looking for are affected. If that looks good, add the -i argument and your files will get updated.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html