I am facing an issue where I am using awk to find a line and print two lines aboveInside the file test.txt file is below{ TABLE sacro.issue row size = 149 number of columns = 9 index size = 0 }{ unload file name = issue00106.unl number of rows = 74 }create table sacro.issue( issue_no serial not null constraint sacro.nnc_issue00,user_logged varchar(8,1) not null constraint sacro.nnc_issue01,issue_status_code integer not null constraint sacro.nnc_issue02,issue_cat_code varchar(2) not null constraint sacro.nnc_issue03,issue_descr text not null constraint sacro.nnc_issue04,issue_feedback text,user_action varchar(8,1),date_logged date not null constraint sacro.nnc_issue05,date_compl date);revoke all on sacro.issue from public as sacro;{ TABLE sacro.issue_category row size = 104 number of columns = 2 index                        size = 8 }{ unload file name = issue00107.unl number of rows = 5 }create table sacro.issue_category(issue_cat_code varchar(2) not null constraint sacro.nnc_iss_cat00,issue_cat_descr varchar(100),primary key (issue_cat_code)  constraint sacro.pkc_issuecategory);revoke all on sacro.issue_category from public as sacro;{ TABLE sacro.issue row size = 149 number of columns = 9 index size = 0 }{ unload file name = issue00106.unl number of rows = 74 }The line I am searching for is below:create table sacro.issueThe command I am running is:cat test.txt | awk '{a[NR]=$0} $0~s {f=NR} END {for (i=f-B;i<=f+A;i++) print a[i]}' B=2 A=0 s='create table \sacro\.issue'When I run the command it finds the line create table sacro.issue_category. Is there a way to grep for the line I need as if I was using grep -w. Unfortunately the below grep command does not work on HPUX:cat test.txt | grep -B 2 -w create table \sacro\.issue | head -1My desired outcome should be (using head -1):{ unload file name = issue00106.unl number of rows = 74 }
How to awk unique line and print 2 lines above
linux;awk;hp ux