Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: list files that are not with a given extension

Tags:

bash

shell

I was wondering if there is a way to ls files in a folder that does not have a given extension? For example, if I have a folder full of .cpp and .h files, and I wanted to see if there are other types of files (such as config files and make files), how do I list or find?

Thanks,

like image 248
thor Avatar asked Jan 27 '26 17:01

thor


1 Answers

You can use find:

find . -maxdepth 1 ! \( -name "*.cpp" -o -name "*.h" \)
like image 153
anubhava Avatar answered Jan 29 '26 08:01

anubhava