Find files NOT ending in specific extensions

This post provides instructions on how to find files NOT ending in specific file extension(s) when a folder contains many many files on Linux (tested on Ubuntu and CentOS)  and Mac OS.

Open a terminal, and

cd into the folder you would like to list the file extensions.

In your terminal, issue the following command :

$ find . ! \( -name "*.py" -o -name "*.exe" \)

This will list all files that are not a .py file and not a .exe file (change the file extension(s) name according to your name:)).

 

$ find . ! \( -name "*.exe" \)

This will list all files that are not a .exe file.

 

$ find . ! \( -iname "*.exe" \)

This will list all files that are not a .exe or .EXE file.

Note:  -name is case sensitive while -iname is case insensitive.

 

For more commonly used Linux commands, check my other posts at here  and here .

Leave a Reply

Your email address will not be published. Required fields are marked *