>>>>> "Robert" == Robert Thorsby <[EMAIL PROTECTED]> writes:

Robert> On 2004.12.15 10:10 Roger Barnes wrote:
>> I'm trying to think of a way that doesn't use an intermediate file,
>> not that it would be any more efficient given the whole file will
>> be re-written no matter what you do.  I tried using less with
>> unlimited memory buffers (-b-1) instead of cat, but it doesn't work
>> any better, probably because of how pipes work.

Robert> Will this do:

Robert> #!/bin/bash

Robert> STATIC_FILE=`/bin/cat << "EOF" jumps over the lazy dog down by
Robert> the river side.  EOF`

Robert> BASH_VAR_1="The quick" BASH_VAR_2="brown fox"

Robert> echo "$STATIC_FILE" | /bin/gawk -v i="$BASH_VAR_1" -v
Robert> j="$BASH_VAR_2" 'BEGIN { print i print j } { print ($0) }'

This just puts the bits on standard out.  I thin khte ideas was to
rewrite the file once.

I'd use an ed script for this.

  ed file > /dev/null <<EOF
  1i
  New Stuff Here
  On as many lines as you want
  you can even include ${SHELL_VARIABLES} if you want
  .
  w
  q
  EOF



Peter C
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to