Hi,
Our ERP system on SUSE can print reports to a printer or an ASCII file. I am writing a script to strip away all the page header/footer content from the ASCII file, leaving just the data, so that it can be imported into another program.
I've got most of this stuff cleaned out, but I'm left with the column headers, which are repeated at the top of each page.
I am tryting to find out if there is some sed command for deleting all but the first occurence of a line.
I can't use uniq because there might be duplicate lines within the data that I don't want to delete.
I can do it like this:
Code:
hdr=$(head -1 file)
echo $hdr > newfile
cat file | sed '/$hdr/d' >> newfile
or
cat file | grep -v $hdr >> newfile
This works fine, but I was wondering if there might be some sed trick to this that might work better.
Thanks.