pickarooney
December 24th, 2006, 12:57 PM
I'm trying to test for the existence of a file type and perform an action on all files of that type, but don't want to get an error output if the filetype doesn't exist.
Both snippets below throw up errors depending on whether or not the filetype exists.
if [ -f *.txt ]
then
rm *.txt
fi
or
for file in *.txt
do
rm $file
done
Both snippets below throw up errors depending on whether or not the filetype exists.
if [ -f *.txt ]
then
rm *.txt
fi
or
for file in *.txt
do
rm $file
done