Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from stackoverflow.com Apr 23 '12 at 22:34

This question came from our site for professional and enthusiast programmers.

3  
Next time you should try to read man YOURCOMMAND (in this case find) first. – Zsolt Botykai Apr 23 '12 at 8:25
    
@PaulR: If you don't use regexexs, maybe, but both, find and locate, can handle regex, and therefore it can be alright here, imho. – user unknown Apr 23 '12 at 21:58
 find -name "*.jpg" -o -name "*.css"
share|improve this answer
    
thanks that worked. – Johny Emmanuel Tsuen Apr 23 '12 at 9:33
    
This ./ seems a bit unnecessary here? – Bernhard Apr 24 '12 at 20:46
    
@JohnyEmmanuelTsuen Please accept is as the answer then. – Bernhard Apr 24 '12 at 20:46

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"
share|improve this answer

Alternatively, you can type :

find -name "*.jpg" -or -name "*.css" 
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .