Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gnu grep "feature"....

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
there are -A and -B switches for gnugrep. I am using AIX grep which doesn't support it, so my question is what is the best replacement for it? awk?

how to get n lines starting from matched line or n lines before the matched line using awk?

1. including matched line
2. not including the matched line

regards, m.
 
Here's a little trick:
Code:
s2(~)$ diff -C 3 <( grep -v brunson /etc/passwd ) /etc/passwd  | grep -v -e '^\*' -e '^-'
  squid:x:23:23::/var/spool/squid:/dev/null
  webalizer:x:67:67:Webalizer:/var/[URL unfurl="true"]www/usage:/sbin/nologin[/URL]
  john:x:500:500::/home/john:/bin/bash
+ brunson:x:501:501::/home/brunson:/bin/bash
  peg:x:502:502::/home/peg:/bin/bash
  jboss:x:503:503::/home/jboss:/bin/bash
  mysql:x:504:504::/home/mysql:/bin/bash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top