in reply to Replace Last Line in Filein thread search and replace last line
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.