[SunHELP] insert one line at beginning of text file; efficien tly
Phil Stracchino
alaric at caerllewys.net
Wed Sep 3 16:21:02 CDT 2003
On Wed, Sep 03, 2003 at 04:48:24PM -0400, Dale Ghent wrote:
> On Wednesday, September 3, 2003, at 03:39 PM, Markham, Richard wrote:
>
> >Dale if you dont mind if I wanted to pass paramers ($1 $2 .....) to
> >theis
> >perl
> >command how can I get it to go through without PERL trying to process
> >the
> >variable. Appears the shell never gets to replace the variable value.
>
> Use this perl script instead. Cut and past it into a file, make it
> executable, and run it like so: ./foo inputfile argument > outputfile
>
> #!/usr/bin/perl
>
> print "$ARGV[1]\n";
> open FILE, $ARGV[0];
> while(<FILE>){print;}
Don't you think it's a bit wasteful starting up a whole Perl interpreter
to do something this trivial?
[ A close(FILE); when you're done would probably be a good idea, too.]
For maximal speed, try this: Create a file foo containing a single
newline, then for each input file bar, just:
cat foo bar > baz
(or cat foo bar | next command....)
--
.********* Fight Back! It may not be just YOUR life at risk. *********.
: phil stracchino : unix ronin : renaissance man : mystic zen biker geek :
: alaric at caerllewys.net : alaric-ruthven at earthlink.net : phil at latt.net :
: 2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold) :
: Linux Now! ...Because friends don't let friends use Microsoft. :
More information about the SunHELP
mailing list