- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Grep command
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
тАО12-01-2006 06:33 AM
тАО12-01-2006 06:33 AM
is there a way to grep this string "tw008070432"
in the file ltdbgout32700 as below and then print out that line and 5 line a bove and 5 line below that result.
$grep -in tw008070432 ltdbgout32700
189596:0x77ff1678: 44203D20 27545730 30383037 30343332 |D = 'TW008070432|
189601:e from DIST_G where DIST_ID = 'TW008070432' -0
Regards,
Tom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2006 06:59 AM
тАО12-01-2006 06:59 AM
Re: Grep command
I've been playing with this bit of sed code (from "Handy One-Liners for SED" - attached) for the last few minutes, trying to get it to print more than just one line before and after:
# print 1 line of context before and after regexp, with line number
# indicating where the regexp occurred (similar to "grep -A1 -B1")
sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h
I've also tried playing with grep, but can't find any sort of -A1 -B1 syntax.
Maybe you can figure something out that I'm not seeing.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2006 07:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2006 07:45 AM
тАО12-01-2006 07:45 AM
Re: Grep command
# ex -s +/Manager/-5,/Manager/+5 p | q!'file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2006 08:07 AM
тАО12-01-2006 08:07 AM
Re: Grep command
Your question is not infrequent. See this thread for some solutions. You can easily adopt mine or Hein's to process +-5 lines instead of the three in the solution presented.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=988970
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2006 08:32 AM
тАО12-01-2006 08:32 AM
Re: Grep command
sorry Sandman, you should get 10 points.
my fault, did not run the command correctly.
Your suggestion works good.
Thanks again,
Tom