RE: Bash script with env variables

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Carruth, Rusty
Date:  
To: Main PLUG discussion list
Subject: RE: Bash script with env variables
Try:

 

Foo=`eval echo $file`

echo $Foo

 

Or something along those lines.

From:  [mailto:plug-discuss-bounces@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 -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss