[ILUG] Pipe Trimming question ...

Kenn Humborg kenn at bluetree.ie
Thu Feb 22 16:54:55 GMT 2001


> Question,
> Is there an easy way to remove the final line from a file (pref without
> resorting to something akin to 
> head -`wc -l <filename> | awk '{print $2}'` <filename>
> 
> I'd prefer if the solution were pipable 
> 
> myscriptwithoutput.sh | lastlineremover.sh > filename

Something like (untested):

awk ' BEGIN { prev = ""; }
	{
		if (prev != "") {
			print prev;
		}
		prev = $0;
	} '

Later,
Kenn





More information about the ILUG mailing list