>> >From a script: main.sh, I need to:
>> 1. Copy file ./x to /tmp/x
>> 2. Read a variable from stdin, for example: read VALUE
>> 3. Search through file /tmp/x for the keyword REPLACE, and replace it
with ${VALUE}
>> 
>> I can't seem to figure out what combination of sed, perl, whatever I can
use.
>> 
>> main.sh:
>> #!/bin/sh
>> 
>> cp ./x /tmp/x
>> read VALUE
>> 
>> # what I really want, but doesn't work:
>> sed 's/REPLACE/${VALUE}/g' /tmp/x > /tmp/x.new


sed "s/REPLACE/${VALUE}/g" ./x > /tmp/x
should work (inside ' the variable is not expanded, thought it is inside ")
the only constraint is that you have no / in its value, sed wouldn't like it
also don't bother copying the file before "sed"'ing it

hth


                        - * - * - * - * - * - * -
Bien sûr que je suis perfectionniste !
Mais ne pourrais-je pas l'être mieux ?
        Thierry ITTY
eMail : [EMAIL PROTECTED]               FRANCE



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to