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.

  • Do you want the last 8 lines, or everything but the last 8 lines? – Kerrek SB Jun 28 '11 at 1:57

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
  • Thanks! Wow i thought the -n was for a numeric offset. I'll give it try! – chrisjlee Jun 28 '11 at 2:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.