Unix Shell - shell substitution

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > shell substitution





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author shell substitution
rickm@galaxy.nsc.com

2007-12-19, 7:27 pm

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
Lew Pitcher

2007-12-19, 7:27 pm

On Dec 19, 2:51 pm, ri...@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


Bill Marcum

2007-12-19, 7:27 pm

On 2007-12-19, Lew Pitcher <lpitcher@teksavvy.com> wrote:
>
>
> On Dec 19, 2:51 pm, ri...@galaxy.nsc.com wrote:
>
> I need to subtitute $FILENAME
>
>

sed "s|FILENAME|$FILENAME|g" file > newfile
Michael Tosch

2007-12-20, 7:35 am

rickm@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 @ hp : com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com