How can I search a wild card name in all subfolders?
Clash Royale CLAN TAG#URR8PPP
How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s
in *nix?
shell wildcards recursive
add a comment |
How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s
in *nix?
shell wildcards recursive
add a comment |
How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s
in *nix?
shell wildcards recursive
How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s
in *nix?
shell wildcards recursive
shell wildcards recursive
edited Sep 11 '12 at 23:43
Gilles
543k12811001618
543k12811001618
asked Sep 11 '12 at 16:08
Eduard FlorinescuEduard Florinescu
3,486103956
3,486103956
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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*'
add a comment |
Zsh:
ls -ld -- **/*abcd*
Ksh93:
set -o globstar # put this line in your ~/.kshrc
ls -ld -- **/*abcd*
Bash ≥4:
shopt -s globstar # put this line in your ~/.bashrc
ls -ld -- **/*abcd*
Yash:
set -o extendedglob # put this line in your ~/.yashrc
ls -ld -- **/*abcd*
tcsh:
set globstar
ls -ld -- **/*abcd*
fish:
ls -ld -- **abcd*
(beware some of those shells will follow symlinks when descending the directory tree; some of those that don't like zsh
, yash
or tcsh
have ***/*abcd*
to do it).
Portable (except to very old systems; OpenBSD took a long time but finally supports exec … +
since 5.1):
find . -name '*abcd*' -exec ls -ld +
Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:
find . -name '*abcd*' -print0 | xargs -0 ls -ld
Note that except in some BSDs, if no matching file is found, ls -ld
will be run without arguments, so will list .
. With some xargs
implementations, you can use the -r
option to work around that.
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down toglobstar
.
– Gilles
Mar 5 '15 at 0:39
add a comment |
Not mentioned in the other answers is
ls -R1 | grep pattern
ls arguments used:
-R, --recursive
list subdirectories recursively
-1 list one file per line
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f47858%2fhow-can-i-search-a-wild-card-name-in-all-subfolders%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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*'
add a comment |
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*'
add a comment |
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*'
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*'
answered Sep 11 '12 at 16:11
Ryan A.Ryan A.
58143
58143
add a comment |
add a comment |
Zsh:
ls -ld -- **/*abcd*
Ksh93:
set -o globstar # put this line in your ~/.kshrc
ls -ld -- **/*abcd*
Bash ≥4:
shopt -s globstar # put this line in your ~/.bashrc
ls -ld -- **/*abcd*
Yash:
set -o extendedglob # put this line in your ~/.yashrc
ls -ld -- **/*abcd*
tcsh:
set globstar
ls -ld -- **/*abcd*
fish:
ls -ld -- **abcd*
(beware some of those shells will follow symlinks when descending the directory tree; some of those that don't like zsh
, yash
or tcsh
have ***/*abcd*
to do it).
Portable (except to very old systems; OpenBSD took a long time but finally supports exec … +
since 5.1):
find . -name '*abcd*' -exec ls -ld +
Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:
find . -name '*abcd*' -print0 | xargs -0 ls -ld
Note that except in some BSDs, if no matching file is found, ls -ld
will be run without arguments, so will list .
. With some xargs
implementations, you can use the -r
option to work around that.
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down toglobstar
.
– Gilles
Mar 5 '15 at 0:39
add a comment |
Zsh:
ls -ld -- **/*abcd*
Ksh93:
set -o globstar # put this line in your ~/.kshrc
ls -ld -- **/*abcd*
Bash ≥4:
shopt -s globstar # put this line in your ~/.bashrc
ls -ld -- **/*abcd*
Yash:
set -o extendedglob # put this line in your ~/.yashrc
ls -ld -- **/*abcd*
tcsh:
set globstar
ls -ld -- **/*abcd*
fish:
ls -ld -- **abcd*
(beware some of those shells will follow symlinks when descending the directory tree; some of those that don't like zsh
, yash
or tcsh
have ***/*abcd*
to do it).
Portable (except to very old systems; OpenBSD took a long time but finally supports exec … +
since 5.1):
find . -name '*abcd*' -exec ls -ld +
Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:
find . -name '*abcd*' -print0 | xargs -0 ls -ld
Note that except in some BSDs, if no matching file is found, ls -ld
will be run without arguments, so will list .
. With some xargs
implementations, you can use the -r
option to work around that.
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down toglobstar
.
– Gilles
Mar 5 '15 at 0:39
add a comment |
Zsh:
ls -ld -- **/*abcd*
Ksh93:
set -o globstar # put this line in your ~/.kshrc
ls -ld -- **/*abcd*
Bash ≥4:
shopt -s globstar # put this line in your ~/.bashrc
ls -ld -- **/*abcd*
Yash:
set -o extendedglob # put this line in your ~/.yashrc
ls -ld -- **/*abcd*
tcsh:
set globstar
ls -ld -- **/*abcd*
fish:
ls -ld -- **abcd*
(beware some of those shells will follow symlinks when descending the directory tree; some of those that don't like zsh
, yash
or tcsh
have ***/*abcd*
to do it).
Portable (except to very old systems; OpenBSD took a long time but finally supports exec … +
since 5.1):
find . -name '*abcd*' -exec ls -ld +
Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:
find . -name '*abcd*' -print0 | xargs -0 ls -ld
Note that except in some BSDs, if no matching file is found, ls -ld
will be run without arguments, so will list .
. With some xargs
implementations, you can use the -r
option to work around that.
Zsh:
ls -ld -- **/*abcd*
Ksh93:
set -o globstar # put this line in your ~/.kshrc
ls -ld -- **/*abcd*
Bash ≥4:
shopt -s globstar # put this line in your ~/.bashrc
ls -ld -- **/*abcd*
Yash:
set -o extendedglob # put this line in your ~/.yashrc
ls -ld -- **/*abcd*
tcsh:
set globstar
ls -ld -- **/*abcd*
fish:
ls -ld -- **abcd*
(beware some of those shells will follow symlinks when descending the directory tree; some of those that don't like zsh
, yash
or tcsh
have ***/*abcd*
to do it).
Portable (except to very old systems; OpenBSD took a long time but finally supports exec … +
since 5.1):
find . -name '*abcd*' -exec ls -ld +
Not POSIX but works on *BSD, Linux, Cygwin, BusyBox:
find . -name '*abcd*' -print0 | xargs -0 ls -ld
Note that except in some BSDs, if no matching file is found, ls -ld
will be run without arguments, so will list .
. With some xargs
implementations, you can use the -r
option to work around that.
edited Feb 24 at 12:53
Stéphane Chazelas
311k57586945
311k57586945
answered Sep 12 '12 at 2:04
GillesGilles
543k12811001618
543k12811001618
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down toglobstar
.
– Gilles
Mar 5 '15 at 0:39
add a comment |
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down toglobstar
.
– Gilles
Mar 5 '15 at 0:39
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
what does shopt -s globstar do??
– user2429920
Mar 5 '15 at 0:23
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down to
globstar
.– Gilles
Mar 5 '15 at 0:39
@user2429920 gnu.org/software/bash/manual/… and click through to gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin then scroll down to
globstar
.– Gilles
Mar 5 '15 at 0:39
add a comment |
Not mentioned in the other answers is
ls -R1 | grep pattern
ls arguments used:
-R, --recursive
list subdirectories recursively
-1 list one file per line
add a comment |
Not mentioned in the other answers is
ls -R1 | grep pattern
ls arguments used:
-R, --recursive
list subdirectories recursively
-1 list one file per line
add a comment |
Not mentioned in the other answers is
ls -R1 | grep pattern
ls arguments used:
-R, --recursive
list subdirectories recursively
-1 list one file per line
Not mentioned in the other answers is
ls -R1 | grep pattern
ls arguments used:
-R, --recursive
list subdirectories recursively
-1 list one file per line
answered Feb 24 at 8:25
Eduard FlorinescuEduard Florinescu
3,486103956
3,486103956
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f47858%2fhow-can-i-search-a-wild-card-name-in-all-subfolders%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown