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

Popular posts from this blog

java - Ebean enhancement ignores a model -

ubuntu - How to disable Kernel Module Signing in linux -

SQL php on different pages to Insert (mysqli) -