1-file of variable enviroments
DIR1=/tmp
DIR2=otherdir/mydir
2-file of list of files (all the names references whic variables of first point)
$\{DIR1\}/$\{DIR2\}/onefile
Well now i create a shell script whic this content
. ./file_of_env
for file in `cat list_of_files`
do
if [ -f ${file} ]
then
.....
else
......
file
done
Well this not work because the valor of variable "file" is :
$\{DIR1\}/$\{DIR2\}/onefile
but if inside the while i put and echo "$DIR1" then enviorement variable is charge.
What i'm doing wrong?
who can i make for the system make the sustituion of the enviorement variable DIR1 and DIR2?
other probe i make is chage the
. ./file_of_env
and put directly the variable definitios of DIR1 and DIR2 but tthe result is the same.
thanks.
---------- Post updated at 05:47 AM ---------- Previous update was at 04:32 AM ----------
Thank you cfajohnson, the list of files does not contain blanks.
Normally I use :
while read line
do
....
done < file_list
i doesn't know UUOC's meaning, I it have looked in google and found other UUOC's cases that i doesn't know they are "bad code" or not optimus code, thank you very much for your contribution.
At the least, an unnecessary cat is a waste of resources (cat is an external command, and therefore much slower than using shell syntax).
At the worst, it will fail. If you use later that script on another file that does have spaces in file names, it will fail. The redirection syntax will always work, giving you a more robust script.