Avoiding errors due to unexpanded asterisk

view full story

http://unix.stackexchange.com – In bash I often use for-loops such as the following for file in *.type; do sommecommand "$file"; done; to perform an operation for all files matching *.type. If no file with this ending is found in the working directories the asterisk is not expanded and usually I will get an error message saying that somecommand didn't find the file. I can immediately think of several ways to avoid this error. But adding a conditional does not seem to be very elegant. Is there a short and clean way to achieve this? (HowTos)