Simple question...
Dave Lawrence
tale at cs.rpi.edu
Sun Dec 3 14:45:20 AEST 1989
In <JGREELY.89Dec2101808 at oz.cis.ohio-state.edu> jgreely at oz.cis.ohio-state.edu
(J Greely) writes:
> Strictly speaking, you need to remove everthing before the first
> line that begins with either "#" or ":", since many shar programs
> produce the latter. [...] The "exit 0" is there specifically to
> prevent the shell from reading the signature.
> sed -n '/^[#:]/,$ p'
> perl -ne 'print if /^[#:]/..eof();'
Perl is overkill in this case since it is doing a job that both awk
and sed can do with less overhead. A little script I tossed together
a long time ago to do the job uses the awk method:
================
#! /bin/sh
files=${*:--}
for file in $files; do
/bin/awk '/^#! ?\/bin\/sh *$/,/^ *exit 0 *$/' $file | /bin/sh
done
================
I've been using this for a couple of years; I suppose I should modify
it to handle the ":" case too, since I've seen a few like that.
For more than one file, a single perl script to handle them all would
be most efficient. For one file, sed is probably best. All three of
them are pretty low overhead for this application, though, so I'm just
nitpicking. :-) As is obvious by the above "unsh", I wasn't exactly
offering the most efficient way either. Just another example to show
the interaction of Unix tools.
Dave
--
(setq mail '("tale at cs.rpi.edu" "tale at ai.mit.edu" "tale at rpitsmts.bitnet"))
More information about the Comp.unix.questions
mailing list