shell script add and remove last line in a file code example Example: linux remove last line from file sed '$d' <file> sed -i '$d' <file> # to edit in place