- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep command - 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
10-21-2003 10:18 AM
10-21-2003 10:18 AM
grep command - help needed
HP-UX10.20. In linux it can be done using
'grep -A n' option.
Thanks,
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 10:40 AM
10-21-2003 10:40 AM
Re: grep command - help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 10:59 AM
10-21-2003 10:59 AM
Re: grep command - help needed
How do I do it using awk. Can you provide some examples.
-Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 12:14 PM
10-21-2003 12:14 PM
Re: grep command - help needed
awk '{
if ( $0 ~ /yourpattern/ ) {
for ( i=0; i
print $0;
}}}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 12:16 PM
10-21-2003 12:16 PM
Re: grep command - help needed
As much as I would like to see the awk solution as well, this is a technique I have used.
You have the line number to start with from your grep -n so ....
sed -n "$your_line_number","$X_line_numbers_out"p $SCRIPT_HOME/$DATA_FILE > $OUT_FILE
Or let starting_line="$your_line_number + 1"
let ending_line="$your_line_number + 5"
sed -n "$starting_line","$ending_line"p $SCRIPT_HOME/$DATA_FILE > $OUT_FILE
Best of luck.
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 12:29 PM
10-21-2003 12:29 PM
Re: grep command - help needed
https://www.beepz.com/personal/merijn/ , http://www.cmve.net/~merijn/ , or or http://www.hpux.ws/merijn/
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 12:36 PM
10-21-2003 12:36 PM
Re: grep command - help needed
ex -s +"g/yourpattern/ .+1,.+numberOfLines |q" filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 12:38 PM
10-21-2003 12:38 PM
Re: grep command - help needed
ex -s +"g/yourpattern/ .+1,.+numberOfLines p|q" filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2003 01:30 PM
10-21-2003 01:30 PM
Re: grep command - help needed
Under OpenVMS the command would be:
$SEARCH/WINDOW=(0,
The 0 being 0 pre-fix lines. Surely you were all dying to know that huh?
In Tru64 you can often use -p for a 'paragraph'. No use there either huh?
I'm a bit dissapointed at the lack of extension in many hpux tools. I like the suggestion of just picking up GNU grep.
In the mean time you coudl use AWK:
awk '/
or PERL (assuring a re-start every occurence:
cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 05:25 AM
10-23-2003 05:25 AM
Re: grep command - help needed
You can still use grep then pipe the stdout to head -n for number of lines to display.
grep
Would display the first 20 lines grep returned.
CIAO