How to use sed to remove the last n lines of a file October 19, 2022 by Tarik I don’t know about sed, but it can be done with head: head -n -2 myfile.txt