|
For loop statement - catch error
I'm having a question about for loops. (bash)
I have the following for example:
for file in `ls *.txt`
do
read file ...
done
Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such file or directory" Script is executed via crontab.
Now I want to catch the above error so I don't get it in my mail any more, but I have no idea how to do this.
I can make an if statement first "if [ -f *.txt ] ...", but there must be a better solution.
Thx.
|