- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh help: list following 3 lines after find a keyw...
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
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
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
06-03-2014 04:32 PM - last edited on 06-05-2014 02:22 AM by Maiko-I
06-03-2014 04:32 PM - last edited on 06-05-2014 02:22 AM by Maiko-I
I have a large files, and some lines include a keyword that I am looking for. Further, I wanted to list next 3 lines following the line that includes the keywork.
Thank you very much for your help!
P.S. This thread has been moved from HP-UX > System Administration o HP-UX > languages. - Hp Forum Moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 01:00 AM - edited 06-06-2014 02:33 AM
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 05:29 AM
06-05-2014 05:29 AM
Re: ksh help: list following 3 lines after find a keyword
In case your site doesn't allow open source software outside of hp.com, you can use awk:
awk '/pattern/{print;getline;print;getline;print;getline;print}' filename
where pattern is whatever keyword(s) you are looking for, and filename is the name of the file.
Bill Hassell, sysadmin
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2014 02:33 AM
06-06-2014 02:33 AM
Re: list following 3 lines after finding a keyword
>In case your site doesn't allow open source software
If you like cryptic commands you can use sed:
sed -e '
/pattern/ {
n; n; n; p
}
d'
Note: sed uses REs and awk uses EREs.
- Tags:
- sed