perl - Finding lines that end with zero and print its sister line -
i have files lines such as:
data;moredata;evenmoredata1;200 data;moredata;evenmoredata1;200 data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0
basically every 2 lines related each other. im trying find best way print lines single 0 , line above or below it. output like.
data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0
$ awk -f';' 'nr%3!=0{f=$nf;a=$0;getline;if(f==0||$nf==0)print a"\n"$0"\n"}' file data;moredata;evenmoredata2;500 data;moredata;evenmoredata2;0 data;moredata;evenmoredata3;0 data;moredata;evenmoredata3;0
Comments
Post a Comment