Bash script with env variables

Eric Cope eric.cope at gmail.com
Wed Oct 24 14:53:12 MST 2012


you named it!
What is that called so I can google it next time?

Thanks again!
Eric

On Wed, Oct 24, 2012 at 2:46 PM, Carruth, Rusty <
Rusty.Carruth at smartstoragesys.com> wrote:

> Try:****
>
> ** **
>
> Foo=`eval echo $file`****
>
> echo $Foo****
>
> ** **
>
> Or something along those lines.****
>
> ****
>
> *From:* plug-discuss-bounces at lists.plug.phoenix.az.us [mailto:
> plug-discuss-bounces at lists.plug.phoenix.az.us] *On Behalf Of *Eric Cope
> *Sent:* Wednesday, October 24, 2012 2:41 PM
> *To:* Main PLUG discussion list
> *Subject:* Bash script with env variables****
>
> ** **
>
> Hello all,****
>
> I was not sure how to google this, so any pointers is appreciated.****
>
> ** **
>
> I have a file, $FILELIST with an absolute file path on every line, with
> the caveat that the first portion of the path is an environment variable.
> For example:****
>
> ** **
>
> $PROJ_ROOT/path/to/file.txt****
>
> $PROJ_ROOT/path/to/another/file.txt****
>
> ** **
>
> My script looks like this:****
>
> ** **
>
> for file in  `cat $FILELIST`****
>
> do****
>
>         if [ -f $file ]****
>
>         then****
>
>                 echo "Copying $file"****
>
>                 cp -f `echo $file` $DEST/.****
>
>         else****
>
>             echo "file not found: $file"****
>
>         fi****
>
> done****
>
> ** **
>
> The problem is that the $file is not evaluated to the path. I just get
> "$PROJ_ROOT/path/to/file.txt' not found.****
>
> ** **
>
> If I copy the text and run "more $PROJ_ROOT/path/to/file.txt" I see it
> just fine.****
>
> ** **
>
> How do I get Bash to evaluate the $PROJ_ROOT env variable for the -f $file?
>
> Thanks,****
>
> Eric****
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20121024/4bf63d1e/attachment.html>


More information about the PLUG-discuss mailing list