Tuesday, June 7, 2011

Getting lines from the matching Line in BOSS GNU/Linux

To get the lines after from matching line use following pattern

input-text | grep -A NUM pattern-to-match

NUM is specify the number lines to printed or taken from input text

for example:

sudo ausearch -f / |grep -A 4 "Jun  8"

2:
To get the lines before from matching line use following pattern

input-text | grep -B NUM pattern-to-match

NUM is specify the number lines to printed or taken from input text

for example:

sudo ausearch -f / |grep -B 4 "Jun  8"

No comments:

Post a Comment

jq command in Linux

 How to access the {"field-name":"cskmetro"} echo "{\"field-name\":\"cskmetro\"}" |jq -r ...