Monday, 2 February 2009

How to remove last line of the file - Shell Programming and Scripting - The UNIX and Linux Forums

The first piece of code allows you to cut a whole block of text from one file to the screen or another file.
eg, you may wish cut a block of text from a log file or even web page using the links -dump command instead of cat.

The script works by matching the text in the first sed statement and then the last text and outputs it to screen.
The last sed removes the last line of text from the output.


cat filename.txt | sed -n "/^first line to to cut/,/last lne to cut/p"| sed '$d'

No comments:

Post a Comment