Hi,
I'm newbie on Unix, and I need to create a script renaming some files. The loop using the "for" command works fine unless there isn't a file to rename. For example:
FLD="/test/fl*"
for FL in $FLD
do
mv $FL /test/file.txt
#other statements....
done
So, if there's no file in the folder the variable FL is assigned with the search string (/test/fl*). I already tried to check if the file really exists:
FLD="/test/fl*"
for FL in $FLD
do
if test '-e $FL'
then
mv $FL /test/file.txt
else
echo "File not found"
fi
done
but the test doest work, it always execute the "then" option.
I wonder if this is an AIX's (ver 5L) particularity, because according to the tutorials I've read the test should work fine on Linux.
Regards,
ZGrande
And sorry for my bad english.
I'm newbie on Unix, and I need to create a script renaming some files. The loop using the "for" command works fine unless there isn't a file to rename. For example:
FLD="/test/fl*"
for FL in $FLD
do
mv $FL /test/file.txt
#other statements....
done
So, if there's no file in the folder the variable FL is assigned with the search string (/test/fl*). I already tried to check if the file really exists:
FLD="/test/fl*"
for FL in $FLD
do
if test '-e $FL'
then
mv $FL /test/file.txt
else
echo "File not found"
fi
done
but the test doest work, it always execute the "then" option.
I wonder if this is an AIX's (ver 5L) particularity, because according to the tutorials I've read the test should work fine on Linux.
Regards,
ZGrande
And sorry for my bad english.