On 6/29/06, Laxminarayan G Kamath A laxminarayan@deeproot.co.in wrote:
On 06/29/06 11:27, Mangesh V Rakhunde wrote:
How can I delete last line from all files from a Directory
for f in * do lines=`cat $f|wc -l` let lines = lines - 1 head -n $lines $f > ${f}.new mv ${f}.new $f done
I am sure the command "sed"(or may be "awk") can somehow do this in just one line .. so wait till a sed guru bangs the hell out of me .. :-)
You can delete the last line of a file like so:
sed '$d" file
Put that in the for loop.
Regards, NMK