I have a file, foo.txt, containing the following lines:
a
b
c
I want a simple command that results in the contents of foo.txt being:
a
b
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using
GNU sed:The
-ioption does not exist inGNU sedversions older than 3.95, so you have to use it as a filter with a temporary file:Of course, in that case you could also use
head -n -1instead ofsed.MacOS:
On Mac OS X (as of 10.7.4), the equivalent of the
sed -icommand above is