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 - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -