Thursday, 15 August 2013

AWK -Print the next to last field of each line of input file -


I have an input file file, of which it is constantly updated with different fields, what do I try to do Print a new file next to the previous fields of each row of the input file: awk '{print $ (NF-1)}' outputfile

error: and awk: (FILENAME = - FNR = 2) Fatal: Attempt to reach Area -1

Need Help Thanks in advance

Someone Hild (the empty rows, or all white space) is on a line with NF 0, so that $ (- 1) to evaluate . In addition, if there is only one field, your code will print out $ 0 which you probably will not want.

  awk 'nf & gt; = 2 {Print $ (NF-1)} ''    

No comments:

Post a Comment