Find Multiple Files in Linux

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

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

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.