Find path that has specific sub directory The Next CEO of Stack OverflowIs it possible to search for a directory/file combination?Recursive find that does not find hidden files or recurse into hidden dirsExclude directory in findFinding a specific file in several sub-directoriesfind path directory in sub directorycopying sub-directories not containing a specific file into another directoryIdentify sub-directories that do not contain a specific string in a specific fileExtract Sub-Directory Path from Partially Known DirectoryFind and delete files, whilst keeping any matching files if in a specific directoryFinding filenames that end in a specific character with or without an extensionFind specific folder path in s3 bucket
Which one is the true statement?
What connection does MS Office have to Netscape Navigator?
Is it professional to write unrelated content in an almost-empty email?
Players Circumventing the limitations of Wish
Point distance program written without a framework
Why is information "lost" when it got into a black hole?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Raspberry pi 3 B with Ubuntu 18.04 server arm64: what chip
What steps are necessary to read a Modern SSD in Medieval Europe?
Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?
how one can write a nice vector parser, something that does pgfvecparseA=B-C; D=E x F;
How did Beeri the Hittite come up with naming his daughter Yehudit?
Does higher Oxidation/ reduction potential translate to higher energy storage in battery?
How to get the last not-null value in an ordered column of a huge table?
Airplane gently rocking its wings during whole flight
What is the process for cleansing a very negative action
What was Carter Burke's job for "the company" in Aliens?
Is it correct to say moon starry nights?
Won the lottery - how do I keep the money?
How do I fit a non linear curve?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
Is there a difference between "Fahrstuhl" and "Aufzug"?
Defamation due to breach of confidentiality
Find path that has specific sub directory
The Next CEO of Stack OverflowIs it possible to search for a directory/file combination?Recursive find that does not find hidden files or recurse into hidden dirsExclude directory in findFinding a specific file in several sub-directoriesfind path directory in sub directorycopying sub-directories not containing a specific file into another directoryIdentify sub-directories that do not contain a specific string in a specific fileExtract Sub-Directory Path from Partially Known DirectoryFind and delete files, whilst keeping any matching files if in a specific directoryFinding filenames that end in a specific character with or without an extensionFind specific folder path in s3 bucket
Consider path in a directory structure
/A/B/C/D
/A/B/C/E
/A/B/O/P
now if I want to list all path which has sub directory C in it, then can it be done through grep?
Expected output:
/A/B/C/D
/A/B/C/E
I tried using grep and find but could not achieve this.
grep find filter
add a comment |
Consider path in a directory structure
/A/B/C/D
/A/B/C/E
/A/B/O/P
now if I want to list all path which has sub directory C in it, then can it be done through grep?
Expected output:
/A/B/C/D
/A/B/C/E
I tried using grep and find but could not achieve this.
grep find filter
add a comment |
Consider path in a directory structure
/A/B/C/D
/A/B/C/E
/A/B/O/P
now if I want to list all path which has sub directory C in it, then can it be done through grep?
Expected output:
/A/B/C/D
/A/B/C/E
I tried using grep and find but could not achieve this.
grep find filter
Consider path in a directory structure
/A/B/C/D
/A/B/C/E
/A/B/O/P
now if I want to list all path which has sub directory C in it, then can it be done through grep?
Expected output:
/A/B/C/D
/A/B/C/E
I tried using grep and find but could not achieve this.
grep find filter
grep find filter
edited 2 days ago
Jeff Schaller♦
44.4k1162143
44.4k1162143
asked Feb 4 '17 at 1:04
user3059993user3059993
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
While ka3ak's answer works, find comes with a parameter "-path" so you can simply use
find . -type d -path "*/c/*"
-path seems also a bit faster:
[hexathos:~/test] $ time find . -regextype posix-extended -regex ".*/c/.*"
./a/b/c/d
./a/b/c/e
real 0m0,013s
user 0m0,010s
sys 0m0,000s
[hexathos:~/test] $ time find . -type d -path "*/c/*"
./a/b/c/d
./a/b/c/e
real 0m0,012s
user 0m0,007s
sys 0m0,003s
add a comment |
You only need find
for this:
find A -type d -regextype posix-extended -regex ".*/C/.*"
For the following directory structure
A
└── B
├── C
│ ├── D
│ └── E
├── C1
│ └── E
└── O
└── P
it would return:
A/B/C/E
A/B/C/D
add a comment |
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%2f342392%2ffind-path-that-has-specific-sub-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
While ka3ak's answer works, find comes with a parameter "-path" so you can simply use
find . -type d -path "*/c/*"
-path seems also a bit faster:
[hexathos:~/test] $ time find . -regextype posix-extended -regex ".*/c/.*"
./a/b/c/d
./a/b/c/e
real 0m0,013s
user 0m0,010s
sys 0m0,000s
[hexathos:~/test] $ time find . -type d -path "*/c/*"
./a/b/c/d
./a/b/c/e
real 0m0,012s
user 0m0,007s
sys 0m0,003s
add a comment |
While ka3ak's answer works, find comes with a parameter "-path" so you can simply use
find . -type d -path "*/c/*"
-path seems also a bit faster:
[hexathos:~/test] $ time find . -regextype posix-extended -regex ".*/c/.*"
./a/b/c/d
./a/b/c/e
real 0m0,013s
user 0m0,010s
sys 0m0,000s
[hexathos:~/test] $ time find . -type d -path "*/c/*"
./a/b/c/d
./a/b/c/e
real 0m0,012s
user 0m0,007s
sys 0m0,003s
add a comment |
While ka3ak's answer works, find comes with a parameter "-path" so you can simply use
find . -type d -path "*/c/*"
-path seems also a bit faster:
[hexathos:~/test] $ time find . -regextype posix-extended -regex ".*/c/.*"
./a/b/c/d
./a/b/c/e
real 0m0,013s
user 0m0,010s
sys 0m0,000s
[hexathos:~/test] $ time find . -type d -path "*/c/*"
./a/b/c/d
./a/b/c/e
real 0m0,012s
user 0m0,007s
sys 0m0,003s
While ka3ak's answer works, find comes with a parameter "-path" so you can simply use
find . -type d -path "*/c/*"
-path seems also a bit faster:
[hexathos:~/test] $ time find . -regextype posix-extended -regex ".*/c/.*"
./a/b/c/d
./a/b/c/e
real 0m0,013s
user 0m0,010s
sys 0m0,000s
[hexathos:~/test] $ time find . -type d -path "*/c/*"
./a/b/c/d
./a/b/c/e
real 0m0,012s
user 0m0,007s
sys 0m0,003s
answered Feb 4 '17 at 7:28
hexathoshexathos
313
313
add a comment |
add a comment |
You only need find
for this:
find A -type d -regextype posix-extended -regex ".*/C/.*"
For the following directory structure
A
└── B
├── C
│ ├── D
│ └── E
├── C1
│ └── E
└── O
└── P
it would return:
A/B/C/E
A/B/C/D
add a comment |
You only need find
for this:
find A -type d -regextype posix-extended -regex ".*/C/.*"
For the following directory structure
A
└── B
├── C
│ ├── D
│ └── E
├── C1
│ └── E
└── O
└── P
it would return:
A/B/C/E
A/B/C/D
add a comment |
You only need find
for this:
find A -type d -regextype posix-extended -regex ".*/C/.*"
For the following directory structure
A
└── B
├── C
│ ├── D
│ └── E
├── C1
│ └── E
└── O
└── P
it would return:
A/B/C/E
A/B/C/D
You only need find
for this:
find A -type d -regextype posix-extended -regex ".*/C/.*"
For the following directory structure
A
└── B
├── C
│ ├── D
│ └── E
├── C1
│ └── E
└── O
└── P
it would return:
A/B/C/E
A/B/C/D
edited Feb 4 '17 at 9:44
answered Feb 4 '17 at 6:58
ka3akka3ak
573618
573618
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%2f342392%2ffind-path-that-has-specific-sub-directory%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