shell substitution

There has been a number of old threads on this but non looked like
they worked

I have a shell env varible and a file that has a generic name. The
resolved shell var needs to be substituted in that spot:

setenv FILENAME /path/to/myfile.txt

the file has some text:

I need to subtitue FILENAME

end result:

I need to subtitue path/to/myfile.txt

Thanks
RickM [ Mi, 19 Dezember 2007 20:51 ] [ ID #1889998 ]

Re: shell substitution

On Dec 19, 2:51 pm, ri... [at] galaxy.nsc.com wrote:
> There has been a number of old threads on this but non looked like
> they worked
>
> I have a shell env varible and a file that has a generic name. The
> resolved shell var needs to be substituted in that spot:
>
> setenv FILENAME /path/to/myfile.txt
>
> the file has some text:
>
> I need to subtitue FILENAME

I need to subtitute $FILENAME

> end result:
>
> I need to subtitue path/to/myfile.txt
>
> Thanks
Lew Pitcher [ Mi, 19 Dezember 2007 21:24 ] [ ID #1890000 ]

Re: shell substitution

On 2007-12-19, Lew Pitcher <lpitcher [at] teksavvy.com> wrote:
>
>
> On Dec 19, 2:51 pm, ri... [at] galaxy.nsc.com wrote:
>> There has been a number of old threads on this but non looked like
>> they worked
>>
>> I have a shell env varible and a file that has a generic name. The
>> resolved shell var needs to be substituted in that spot:
>>
>> setenv FILENAME /path/to/myfile.txt
>>
>> the file has some text:
>>
>> I need to subtitue FILENAME
>
> I need to subtitute $FILENAME
>
>> end result:
>>
>> I need to subtitue path/to/myfile.txt
>>
>> Thanks
>
sed "s|FILENAME|$FILENAME|g" file > newfile
Bill Marcum [ Mi, 19 Dezember 2007 22:24 ] [ ID #1890003 ]

Re: shell substitution

rickm [at] galaxy.nsc.com wrote:
> There has been a number of old threads on this but non looked like
> they worked
>
> I have a shell env varible and a file that has a generic name. The
> resolved shell var needs to be substituted in that spot:
>
> setenv FILENAME /path/to/myfile.txt
>
> the file has some text:
>
> I need to subtitue FILENAME
>
> end result:
>
> I need to subtitue path/to/myfile.txt
>
> Thanks


sed "s#FILENAME#$FILENAME#" file

awk '{sub("FILENAME",f);print}' f=$FILENAME file

--
Michael Tosch [at] hp : com
Michael Tosch [ Do, 20 Dezember 2007 10:01 ] [ ID #1891061 ]
Linux » comp.unix.shell » shell substitution

Vorheriges Thema: Can we grep a list of all running PIDs in a file !!??
Nächstes Thema: Dynamic Variable Name