- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Quick Script Command to Find/Insert a line
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
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
07-28-2004 01:22 AM
07-28-2004 01:22 AM
I'm looking for some quick expertise with sed/awk or anything other command that might work for me. I need to search a text file for "echo $x", each time "echo $x" is found, I need to insert "echo $y" on the line below it.
Thank you in advance!!!
Tommy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 01:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 01:59 AM
07-28-2004 01:59 AM
Re: Quick Script Command to Find/Insert a line
-- test.file --
itrc forums
test log entry to test
HELLO
bye for now
test will be thhere
HELLO
it is a test for log test
test over
If you want to put HAI below to HELLO then,
sed -e 's/^HELLO$/HELLO\
HAI/g' test.file
It will do that change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 02:05 AM
07-28-2004 02:05 AM
Re: Quick Script Command to Find/Insert a line
--- test.log ---
itrc forums
test log entry to test
HELLO
bye for now
test will be thhere
it is a test for log test
HELLO
test over
To insert BYE after the pattern HELLO then,
awk '{ if ($0 == "HELLO" print $1 "\nBYE"
else $0 }' test.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 02:15 AM
07-28-2004 02:15 AM
Re: Quick Script Command to Find/Insert a line
# perl -pi -e'm/\becho\s*\$x\b/&&s/$/\necho \$y/' your_file
it is even safe against not inserting after 'echo $xb' or after 'becho $x'
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 02:24 AM
07-28-2004 02:24 AM
Re: Quick Script Command to Find/Insert a line
Tommy