- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sed and awk help needed
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
05-26-2003 07:44 AM
05-26-2003 07:44 AM
I have been trying to work out a solution using sed and awk on a file but am having no joy. I am hoping someone can help me.
I have a text file which is like the following:
DESCRIPTION "OV_Testing"
CONDITION_ID "nnndjdj"
CONDITION "JDJKDKDK"
$e "jdjdjdj"
$G jsjdj
$S 5606060
SET
SERVERLOGONLY
SEVERITY Normal
NODE IP kkdkdkdk
OBJECT "<$2>"
In the file I need to search for all the occurences of OV_Testing and then change the OBJECT "<$2>" to OBJECT "<$r>".
I can match the OV_Testing without any problems but I do not know how to change the value of OBJECT when I have matched the OV_Testing field in the block of text.
Any help would be greatly appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2003 08:08 AM
05-26-2003 08:08 AM
Re: Sed and awk help needed
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2003 08:28 AM
05-26-2003 08:28 AM
Re: Sed and awk help needed
let say the file is named goofy
cat goffy | awk '/OV_Testing/, /\$2/' | sed s.\$2.whatdoyouwant. > destination
now destination keeps the modified nodes.
you can merge this with the source goofy, for example using diff .
Just an hint...
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2003 08:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2003 08:46 AM
05-26-2003 08:46 AM
Re: Sed and awk help needed
# perl -pi.prv -e'm/^DESCRIPTION "([^"]+)/ and$desc=$1;m/^OBJECT/&&$desc eq"OV_Testing"and s/<\$2>/<\$r>/' your_file
Much better. (sed is shorter, but this was inline editing)
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2003 09:09 AM
05-26-2003 09:09 AM
Re: Sed and awk help needed
Thanks, but of course, I neglected to show that, unlike with perl, no inline editing is possible :-))
Hence, I would write:
# sed -e '/OV_Testing/,/OBJECT/ s/"<$2>"/"<$r>"/' filename > filename.new
# mv filename.new filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2003 03:13 AM
05-27-2003 03:13 AM
Re: Sed and awk help needed
cat file | sed 's/OBJECT \"<\$2>\"/\"<\$r>\"/g' > outfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2003 11:13 AM
05-27-2003 11:13 AM