This has probably been asked before, but searching for the word "for" is not the easiest thing...
I have a simple for loop such as:
for x in *.log
do
echo $x
done
This works fine except in the situation where there are no log file, in which case it returns the input criterion ("*.log"). I've got round it in the past by putting in a line to exit the loop if what I get back the same string that I was searching for, but I can't help thinking there must be a better way.
I have a simple for loop such as:
for x in *.log
do
echo $x
done
This works fine except in the situation where there are no log file, in which case it returns the input criterion ("*.log"). I've got round it in the past by putting in a line to exit the loop if what I get back the same string that I was searching for, but I can't help thinking there must be a better way.