- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl/Sed Question
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
03-28-2007 03:18 AM
03-28-2007 03:18 AM
Requirement : I have this application build procedure in which I need to manually modify the attached file in order for me to change the tags (Tg_SysTest_030607) and change it with a new tag.
I would need a script which propmts me for changing the tags and changes the tags in the following places in the attached file :
....
SAZ.corba.tag=Tg_SysTest_030607
...
SAZ.ejb.tag=Tg_SysTest_030607
...
SAZ.web.tag=Tg_SysTest_030607
...
SAZ.config.tag=Tg_SysTest_030607
...
SAZ.tag=Tg_SysTest_030607
...
JAZ.ejb.tag=Tg_SysTest_030607
...
JAZ.web.tag=Tg_SysTest_030607
...
JAZ.config.tag=Tg_SysTest_030607
...
JAZ.tag=Tg_SysTest_030607
...
LAZ.corba.tag=Tg_SysTest_030607
...
LAZ.ejb.tag=Tg_SysTest_030607
...
LAZ.web.tag=Tg_SysTest_030607
...
LAZ.config.tag=Tg_SysTest_030607
...
LAZ.tag=Tg_SysTest_030607
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:21 AM
03-28-2007 03:21 AM
Re: Perl/Sed Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:25 AM
03-28-2007 03:25 AM
Re: Perl/Sed Question
can't you do a:
sed "1,$ s/Tg_SysTest_030607/Tg_SysTest_030707/g" build_0607.sh > build_0707.sh
or use a variable ($builddate) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:29 AM
03-28-2007 03:29 AM
Re: Perl/Sed Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:32 AM
03-28-2007 03:32 AM
SolutionThis looks for the pattern "tag=" and substitutes "Tg_SysTest_999999" for whatever follows it.
# perl -pi.old -e 's{(.+tag=)(.+)}{\1Tg_SysTest_999999}' file
A backup copy of the original input file is made as "file.old" and your modified file left inplace.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:38 AM
03-28-2007 03:38 AM
Re: Perl/Sed Question
Hunki, Clay really has valuable advice here. Think about it! We have all seen you ask many questions here. It is (more than) time for you to revisit those question and ALL the answers, also the once which might not have seen pertinent, and learn from them
It is a huge disspointment to see you come back with what seems to be a trivial question at this point in time.
For the problem itself, I would just use a perl or sed one-liner, with at tight a match as you can find for the .tag= lines.
Something like:
perl -pe 's/^(\S+\.tag=).*/${1}my_test_tag/' old > new
So this instructs perl to look for lines starting with non-spaces and the string ".tag=" and to remember all that in $1
substitute that, and the rest (the old tag captured with .*) with the remembered strign and the new tag value.
Good luck, and do try some more yourself first!
[Oh, Go give yourself 5 points for providing a clear input data example! :-]
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:41 AM
03-28-2007 03:41 AM
Re: Perl/Sed Question
Thanks,
hunki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2007 03:43 AM
03-28-2007 03:43 AM