Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s in *nix?

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

You can use find. If, for example, you wanted to find all files and directories that had abcd in the filename, you could run:

find . -name '*abcd*'
share|improve this answer
add comment

Zsh:

ls -l **/*abcd*

Ksh:

set -o globstar     # put this line in your ~/.kshrc
ls -l **/*abcd*

Bash ≥4:

shopt -s globstar   # put this line in your ~/.bashrc
ls -l **/*abcd*

Portable (except to very old systems; OpenBSD took a long time but finally supports exec … + since 5.1):

find . -name '*abcd*' -exec ls -l {} +

Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:

find -name '*abcd*' -print0 | xargs -0 ls -l
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.