Overwrite last field in last line using awk -
i overwrite last field (2 fields in total) of last line of file value -9. using command:
awk 'end{$2=-9}1' file.txt > new_file.txt
but doesn't seem work (no replacement done). why's that? ideas?
thanks!
you'll need print previous line, , can manipulate last line in end block before has been printed:
awk 'nr > 1 {print prev} {prev = $0} end {$2=-9; print}'
Comments
Post a Comment