Link to home
Start Free TrialLog in
Avatar of tr5
tr5

asked on

Need sed script to remove last line from file.

Hi

I need a sed script (or other) to remove the last line from a file and to resave to the same file.

Thanks
tr5
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sed equivalent will be

 sed '$d' infile > tempfile
 mv tempfile infile
Avatar of tr5
tr5

ASKER

Which is quicker / more efficient? I need to do it often.
Both should have comparable performance since both scan input for lines. Head might be slightly more efficient since this is the job it is built for - displaying specific lines.
Avatar of tr5

ASKER

Thanks