Bash script with env variables
Eric Cope
eric.cope at gmail.com
Wed Oct 24 14:41:23 MST 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20121024/4a31f447/attachment.html>
More information about the PLUG-discuss
mailing list