sam() { cat sam | awk 'BEGIN{a="'$1'";s=0} {if($0~a) {s=s+1} {if(s==1) {print $0}} {if(s==2) {s=0}}}'; }
cat sam
trigger
hi
this
is
sam
trigger
this
line
will
not
display
trigger
this
line
will
be
on
display
trigger
bye
usage:
sam trigger
eptuwya@JDQ08R1:~$ sam() { cat sam | awk 'BEGIN{a="'$1'";s=0} {if($0~a) {s=s+1} {if(s==1) {print $0}} {if(s==2) {s=0}}}'; }
eptuwya@JDQ08R1:~$ vim sam
eptuwya@JDQ08R1:~$ sam trigger
trigger
hi
this
is
sam
trigger
this
line
will
be
on
display
cat sam
trigger
hi
this
is
sam
trigger
this
line
will
not
display
trigger
this
line
will
be
on
display
trigger
bye
usage:
sam trigger
eptuwya@JDQ08R1:~$ sam() { cat sam | awk 'BEGIN{a="'$1'";s=0} {if($0~a) {s=s+1} {if(s==1) {print $0}} {if(s==2) {s=0}}}'; }
eptuwya@JDQ08R1:~$ vim sam
eptuwya@JDQ08R1:~$ sam trigger
trigger
hi
this
is
sam
trigger
this
line
will
be
on
display