Find multiple files in linux

I am searching for files in linux and am able to execute the command to search for a single type of format e.g *.jpg but would like to find all files with *.jpg and *.css in one command.

2

3 Answers

 find -name "*.jpg" -o -name "*.css"
1

There is a fingerbreaking variant with regex:

find -regex ".*\.\(css\|jpg\)" 

It's shorter and avoid pitfalls, combined with the -o versions:

find ./ -name "*.jpg" -o -name "*.css" -ls 

The ls is only adapted to the second pattern, here. You can avoid it with

find ./ \( -name "*.jpg" -o -name "*.css" \) -ls 

but that is getting a bit cryptic too.

Very fast for searching your whole system in the update-db-index is locate, which knows regex too, but doesn't find ultra fresh files:

locate -r "Frame.\(scal\|jav\)a"
1

Alternatively, you can type :

find -name "*.jpg" -or -name "*.css" 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like