hello team -
anyone can help shwoing how to grep a file showing the lines above and below?
Thx
Bragabio
hello team -
anyone can help shwoing how to grep a file showing the lines above and below?
Thx
Bragabio
grep -B1 -A1 "searchme" input_file
--ahamed
in awk ..
$ awk '/pattern/{print x};{x=$0}' ## before
$ awk '/pattern/{getline;print}' ## after
awk '/searchme/{print pre;print;getline;print}{pre=$0}' input_file
--ahamed
using sed ..
$ sed -n '/pattern/{g;1!p;};h' ## before
$ sed -n '/pattern/{n;p;}' ## after
awsome!!! it worked fine!
Using sed...
sed -n '{H;/searchme/{n;H;x;s/.*\n\(.*\n.*\n\)/\1/;p}}' input_file
--ahamed