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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -