Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I want to tail a file and remove the number of lines from the file is that possible with one line line in Linux? Almost essentially just moving lines of text from one file to another.

For example:

tail -8 foo-file.txt >> newfile.txt;

now... remove -8 lines from newfile.txt.

share|improve this question
Do you want the last 8 lines, or everything but the last 8 lines? – Kerrek SB Jun 28 '11 at 1:57
up vote 3 down vote accepted

Your example is close, you just need to change the way you are asking for the lines. Below I changed your "-8" to "-n 8" to ask for 8 lines.

tail -n 8 foo-file.txt >> newfile.txt
share|improve this answer
Thanks! Wow i thought the -n was for a numeric offset. I'll give it try! – chrisjlee Jun 28 '11 at 2:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .