I\'m writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I\'ve found that the following code loops all files th
Do
find /path/to/look -type f -not -name "*.txt" -print0 | while read -r -d '' file_name do echo "$file_name" done
when your filenames may be nonstandard.
Note:
If you don't wish to recursively search for files in subfolders include -maxdepth 1 just before -type f.
-maxdepth 1
-type f