Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find question again 2

Status
Not open for further replies.

nimrodman

MIS
Nov 22, 2005
43
US
Can I use find to look for multiple file types in a single line command, e.g, it is possible to run something like
find . -name '*.txt, *.doc and so on in a single line?

I tried it but it did not work, thanks for your assistance.
 
Just join the different -name options with -o (or)

[tt]find /your/dir -name '*.txt' -o -name '*.doc' -print[/tt]

Check out the man page for more info.


HTH,

p5wizard
 
I'd use parenthesis when mixing or & and operators:
find /your/dir \( -name '*.txt' -o -name '*.doc' \) -print

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Once again, I stand corrected, PHV [blush].

but this may also work:

[tt]find /your/dir -name '*.txt' -o -name '*.doc'[/tt]

most [tt]find[/tt]s nowadays report the found pathnames as per default.


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top