1. SED SED SED...
Post follow-ups to comp.unix.questions, please.
| Is this simple or what: I want to erase the last 4 lines of a
| thousand files with variable length (I want to do more than
| that but I have succeded in the rest). I have tried $-4,$ d
| in sed (and many MANY variants of this) but it wont do.
| I have ended up using $ d (which works!!!) four times, but
| this makes my scripts long and the procces four times slower!!!
sed has no idea when it has reached $-4 or $-3, only when it has reached $.
Suggestion #1 -- if it must be done with sed, here goes:
Under GNU sed and possibly under BSD sed, it will require a -n flag to
operate properly on files of three or fewer lines, but one wouldn't run it
on files that short anyway. -n won't hurt under System V, but it isn't
necessary, and no implementation of sed should need -n for files of four
lines or more.
Suggestion #2 -- forget sed:
ed - file << \FOOF
[$-4,$ d would delete the last FIVE lines. Ranges are inclusive.]
Suggestion #3 -- some perl fan will write it in perl.
David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297
2. oops / NFS
3. . 2 sed FAQs, sed exes, sed cetras; URLs
4. X & Chips F65530
5. (sed 1q ; sed 2q) : no output from 2nd 'sed'
6. Scanner ACER Vuego Scan Brisa 620S
7. . sed script dc greg ubben sed stud
8. How do I set mutiple domains with linux
9. to all sed hackers - joining lines with sed
10. better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
11. aix 3.2 - see sed run, run sed run
12. another tough sed problem: sed dependency
13. String manipulation error & how to use sed in a sed command?