in reply to Replace Last Line in File
in thread search and replace last line


This prints the last line before it has been changed:     perl -i -pe '$last = $_; s/foo/bar/ if eof; END{print $last}' file

And this changes the last line and then prints it:     perl -i -ne 's/foo/bar/ if eof; print $last = $_; END{print $last}' file

--
John.