This entry is part 14 of 19 in the Bash-whacking series

Delete line containing foo

sed -i '/foo/d' filename.txt
 

Delete last line

sed -i '$d' filename.txt