- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Print from matched string on....
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
тАО01-24-2008 05:56 AM
тАО01-24-2008 05:56 AM
How can I print or get the output from a certain string on...like everything after that string printed out to the screen?
Thanks,
Sally
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:07 AM
тАО01-24-2008 06:07 AM
Solution# cat stuff
this is a file
of stuff
which I want to
dump from here
to the end.
Hence, here it is...
from there to the end.
# sed -ne '/here/,$p' stuff
dump from here
to the end.
Hence, here it is...
from there to the end.
Regards!
...JRF...
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:11 AM
тАО01-24-2008 06:11 AM
Re: Print from matched string on....
For questions like this I always turn to "Handy One-Liners for Sed" (attached) which I found here on the Forums years ago.
Pete
Pete
- Tags:
- missing attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:13 AM
тАО01-24-2008 06:13 AM
Re: Print from matched string on....
awk '/certain string/,0' file.txt
Hein.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:16 AM
тАО01-24-2008 06:16 AM
Re: Print from matched string on....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:23 AM
тАО01-24-2008 06:23 AM
Re: Print from matched string on....
If you mean literally "everything AFTER that string" but not anything that preceeds it on the same line, I'd do it thusly:
# perl -nle 'if ($n) {print} elsif (m/(here.*)/) {print $1;$n++}'
It this example, the string to match is "here". As written it could be a part of the string "where". Thus, if you wanted only the isolated word "here" (at a boundary) , change this to:
# perl -nle 'if ($n) {print} elsif (m/(\bhere\b.*)/) {print $1;$n++}'
Now use this variation and compare the difference of the two:
# cat stuff
this is a file
of stuff
where I want to
dump from here to
the end.
Hence, here it is...
from there to the end.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2008 06:53 AM
тАО01-24-2008 06:53 AM
Re: Print from matched string on....
But I had an extra thought...
'Normally' (is there such thing?) the awk range is used as: /start/,/end/
In my example I used a hardcoded 0 as end test, so the end match is never true (near). It ends when the data ends.
Sometimes I want to see a few lines after a match. I just realized that using a similar technique one could use:
awk '/error/,!++x%5' file.log
This is only a quick and dirty solution.
One would probably want a seperator between matching zones.
And what to do on re-match while in the print zone?
If you solve all that, then it quickly becomes a full blown script.
Cute?
Hein.