How to list files that don't match a glob?
E.g., let's say I have a directory that contains hundreds of files, 97% of which have the filename extension .png
.
I know I can list the PNG files with:
ls *.png
But, how do I list the opposite, i.e., just the non-PNG files?
Using ls:
the quotes are important to stop the shell evaluating the
*
Using find:
If you have subdirectories (with files), you may want to limit the search:
where
-maxdepth 1
limits it to the present directory-type f
only allows it to print files