This question already has an answer here:
Searching a pattern using awk and print next 15 lines from a log file
awk '/^DERAT1SB[0-9][0-9]# show registration/{nr[NR]; nr[NR+4]}; NR in nr' slb.log
I am using above command to search a pattern DERAT1SB23# show registration
inside a log file, but it is throwing a syntax error.
ERROR:
awk: syntax error near line 1
awk: bailing out near line 1
Search for a pattern and print next 15 lines: using GNU sed
With plain awk:
From Effective Awk Programming, Edition 4:
Is a known issue and you should change in your code on a Solaris/SunOS system, change
awk
to/usr/xpg4/bin/awk
,/usr/xpg6/bin/awk
, ornawk