find path excluding doesn't work when permission denied The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara 2019 Community Moderator Election ResultsPermission Denied when downloading DrupalHow to skip “permission denied” errors when running find in Linux?Expected behavior of `find -depth` if execute permission denied for subdirectory?my permission command doesn't work properlyHow can I allow a user to traverse a directory but prevent them confirming the existence of any other files/directoriesACL not honored by mv and tarExplain find's -path and -prune optionsFTP doesn't overwrite - put Permission deniedPermission denied when executing testng.xml via sshPermission Denied while trying to Find file
Would an alien lifeform be able to achieve space travel if lacking in vision?
My body leaves; my core can stay
How did passengers keep warm on sail ships?
Huge performance difference of the command find with and without using %M option to show permissions
What information about me do stores get via my credit card?
60's-70's movie: home appliances revolting against the owners
What do I do when my TA workload is more than expected?
Homework question about an engine pulling a train
Single author papers against my advisor's will?
One-dimensional Japanese puzzle
Drawing arrows from one table cell reference to another
Accepted by European university, rejected by all American ones I applied to? Possible reasons?
What's the point in a preamp?
Are spiders unable to hurt humans, especially very small spiders?
First use of “packing” as in carrying a gun
Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)
Sort list of array linked objects by keys and values
Can a flute soloist sit?
Presidential Pardon
"... to apply for a visa" or "... and applied for a visa"?
Does Parliament need to approve the new Brexit delay to 31 October 2019?
How to determine omitted units in a publication
Why doesn't a hydraulic lever violate conservation of energy?
What is the padding with red substance inside of steak packaging?
find path excluding doesn't work when permission denied
The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
2019 Community Moderator Election ResultsPermission Denied when downloading DrupalHow to skip “permission denied” errors when running find in Linux?Expected behavior of `find -depth` if execute permission denied for subdirectory?my permission command doesn't work properlyHow can I allow a user to traverse a directory but prevent them confirming the existence of any other files/directoriesACL not honored by mv and tarExplain find's -path and -prune optionsFTP doesn't overwrite - put Permission deniedPermission denied when executing testng.xml via sshPermission Denied while trying to Find file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
There is some strange behavior while excluding path from find
:
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
gives:
/home/user/VMs/win/some-file.vmdk
find: ‘/home/user/sandboxes/debian7.amd64.buildd/root/...’: Permission denied
find: ‘/home/user/sandboxes/debian7.amd64.buildd/var/...’: Permission denied
What's wrong?
P.S. unfortunately -prune
doesn't work too:
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
gives more weird results:
/home/user/nemu_vm/win/some-file.vmdk
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
Useful link
linux permissions find
add a comment |
There is some strange behavior while excluding path from find
:
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
gives:
/home/user/VMs/win/some-file.vmdk
find: ‘/home/user/sandboxes/debian7.amd64.buildd/root/...’: Permission denied
find: ‘/home/user/sandboxes/debian7.amd64.buildd/var/...’: Permission denied
What's wrong?
P.S. unfortunately -prune
doesn't work too:
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
gives more weird results:
/home/user/nemu_vm/win/some-file.vmdk
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
Useful link
linux permissions find
Could you replace-path "~/sandboxes/*"
with-path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
Can you confirm you are you looking for regular files namedsome-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path/home/user/sandboxes
(not its content) to be printed or not.
– fra-san
Apr 9 at 12:35
@fra-san Yep, it's about regular files it this case. I wantfind
not to even enter/home/user/sandboxes
– z0lupka
Apr 9 at 13:29
add a comment |
There is some strange behavior while excluding path from find
:
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
gives:
/home/user/VMs/win/some-file.vmdk
find: ‘/home/user/sandboxes/debian7.amd64.buildd/root/...’: Permission denied
find: ‘/home/user/sandboxes/debian7.amd64.buildd/var/...’: Permission denied
What's wrong?
P.S. unfortunately -prune
doesn't work too:
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
gives more weird results:
/home/user/nemu_vm/win/some-file.vmdk
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
Useful link
linux permissions find
There is some strange behavior while excluding path from find
:
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
gives:
/home/user/VMs/win/some-file.vmdk
find: ‘/home/user/sandboxes/debian7.amd64.buildd/root/...’: Permission denied
find: ‘/home/user/sandboxes/debian7.amd64.buildd/var/...’: Permission denied
What's wrong?
P.S. unfortunately -prune
doesn't work too:
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
gives more weird results:
/home/user/nemu_vm/win/some-file.vmdk
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
Useful link
linux permissions find
linux permissions find
edited Apr 9 at 10:43
Jeff Schaller♦
45k1164147
45k1164147
asked Apr 9 at 9:46
z0lupkaz0lupka
1794
1794
Could you replace-path "~/sandboxes/*"
with-path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
Can you confirm you are you looking for regular files namedsome-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path/home/user/sandboxes
(not its content) to be printed or not.
– fra-san
Apr 9 at 12:35
@fra-san Yep, it's about regular files it this case. I wantfind
not to even enter/home/user/sandboxes
– z0lupka
Apr 9 at 13:29
add a comment |
Could you replace-path "~/sandboxes/*"
with-path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
Can you confirm you are you looking for regular files namedsome-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path/home/user/sandboxes
(not its content) to be printed or not.
– fra-san
Apr 9 at 12:35
@fra-san Yep, it's about regular files it this case. I wantfind
not to even enter/home/user/sandboxes
– z0lupka
Apr 9 at 13:29
Could you replace
-path "~/sandboxes/*"
with -path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
Could you replace
-path "~/sandboxes/*"
with -path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
Can you confirm you are you looking for regular files named
some-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path /home/user/sandboxes
(not its content) to be printed or not.– fra-san
Apr 9 at 12:35
Can you confirm you are you looking for regular files named
some-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path /home/user/sandboxes
(not its content) to be printed or not.– fra-san
Apr 9 at 12:35
@fra-san Yep, it's about regular files it this case. I want
find
not to even enter /home/user/sandboxes
– z0lupka
Apr 9 at 13:29
@fra-san Yep, it's about regular files it this case. I want
find
not to even enter /home/user/sandboxes
– z0lupka
Apr 9 at 13:29
add a comment |
2 Answers
2
active
oldest
votes
Your command
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
prints
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
because the default action when no action is supplied is to output the found pathnames. The above pathnames are found, and then those paths are pruned. Pruning a search path does not exclude these pathnames from being printed.
However, if you add -print
to the very end, as in
find "$HOME" -path "$HOME/sandboxes" -prune -o -name 'some-file.vmdk' -print
then those pathnames would not be printed. This is because now you have an explicit action (the -print
), so no default actions are triggered. The -print
only applies to the right hand side of -o
.
Note that the *
is not needed, and that the variable $HOME
is easier to work with than ~
, especially in scripts.
Your first command,
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
very likely does not work as ~
is not expanded within quotes.
Assuming you used $HOME
instead, it also does not prune the search path, which means it would still enter ~/sandboxes
, but it would never print any pathnames from beneath that path. Since it enters the directory, it would still give you the permission errors when it reaches the inaccessibly directories.
Thanks for clarifying! BTWfind "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested
– z0lupka
Apr 9 at 13:23
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would befind "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, wherefalse
is used to prevent any action whenprune
succeeds (sorry for this invasion, Kusalananda).
– fra-san
Apr 9 at 13:34
add a comment |
You can try this way :
find ~ ! -path "*/sandboxes/*" -name 'some-file.vmdk'
Or with -prune :
find ~ -path "*/sandboxes" -prune -o -name 'some-file.vmdk'
but can't find a way to remove the print of ~/sandboxes
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
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%2f511416%2ffind-path-excluding-doesnt-work-when-permission-denied%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
Your command
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
prints
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
because the default action when no action is supplied is to output the found pathnames. The above pathnames are found, and then those paths are pruned. Pruning a search path does not exclude these pathnames from being printed.
However, if you add -print
to the very end, as in
find "$HOME" -path "$HOME/sandboxes" -prune -o -name 'some-file.vmdk' -print
then those pathnames would not be printed. This is because now you have an explicit action (the -print
), so no default actions are triggered. The -print
only applies to the right hand side of -o
.
Note that the *
is not needed, and that the variable $HOME
is easier to work with than ~
, especially in scripts.
Your first command,
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
very likely does not work as ~
is not expanded within quotes.
Assuming you used $HOME
instead, it also does not prune the search path, which means it would still enter ~/sandboxes
, but it would never print any pathnames from beneath that path. Since it enters the directory, it would still give you the permission errors when it reaches the inaccessibly directories.
Thanks for clarifying! BTWfind "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested
– z0lupka
Apr 9 at 13:23
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would befind "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, wherefalse
is used to prevent any action whenprune
succeeds (sorry for this invasion, Kusalananda).
– fra-san
Apr 9 at 13:34
add a comment |
Your command
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
prints
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
because the default action when no action is supplied is to output the found pathnames. The above pathnames are found, and then those paths are pruned. Pruning a search path does not exclude these pathnames from being printed.
However, if you add -print
to the very end, as in
find "$HOME" -path "$HOME/sandboxes" -prune -o -name 'some-file.vmdk' -print
then those pathnames would not be printed. This is because now you have an explicit action (the -print
), so no default actions are triggered. The -print
only applies to the right hand side of -o
.
Note that the *
is not needed, and that the variable $HOME
is easier to work with than ~
, especially in scripts.
Your first command,
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
very likely does not work as ~
is not expanded within quotes.
Assuming you used $HOME
instead, it also does not prune the search path, which means it would still enter ~/sandboxes
, but it would never print any pathnames from beneath that path. Since it enters the directory, it would still give you the permission errors when it reaches the inaccessibly directories.
Thanks for clarifying! BTWfind "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested
– z0lupka
Apr 9 at 13:23
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would befind "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, wherefalse
is used to prevent any action whenprune
succeeds (sorry for this invasion, Kusalananda).
– fra-san
Apr 9 at 13:34
add a comment |
Your command
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
prints
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
because the default action when no action is supplied is to output the found pathnames. The above pathnames are found, and then those paths are pruned. Pruning a search path does not exclude these pathnames from being printed.
However, if you add -print
to the very end, as in
find "$HOME" -path "$HOME/sandboxes" -prune -o -name 'some-file.vmdk' -print
then those pathnames would not be printed. This is because now you have an explicit action (the -print
), so no default actions are triggered. The -print
only applies to the right hand side of -o
.
Note that the *
is not needed, and that the variable $HOME
is easier to work with than ~
, especially in scripts.
Your first command,
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
very likely does not work as ~
is not expanded within quotes.
Assuming you used $HOME
instead, it also does not prune the search path, which means it would still enter ~/sandboxes
, but it would never print any pathnames from beneath that path. Since it enters the directory, it would still give you the permission errors when it reaches the inaccessibly directories.
Your command
find ~ -path "/home/user/sandboxes/*" -prune -o -name 'some-file.vmdk'
prints
/home/user/sandboxes/debian7.amd64.buildd
/home/user/sandboxes/debian9.amd64.buildd
because the default action when no action is supplied is to output the found pathnames. The above pathnames are found, and then those paths are pruned. Pruning a search path does not exclude these pathnames from being printed.
However, if you add -print
to the very end, as in
find "$HOME" -path "$HOME/sandboxes" -prune -o -name 'some-file.vmdk' -print
then those pathnames would not be printed. This is because now you have an explicit action (the -print
), so no default actions are triggered. The -print
only applies to the right hand side of -o
.
Note that the *
is not needed, and that the variable $HOME
is easier to work with than ~
, especially in scripts.
Your first command,
find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'
very likely does not work as ~
is not expanded within quotes.
Assuming you used $HOME
instead, it also does not prune the search path, which means it would still enter ~/sandboxes
, but it would never print any pathnames from beneath that path. Since it enters the directory, it would still give you the permission errors when it reaches the inaccessibly directories.
edited Apr 9 at 13:07
answered Apr 9 at 12:44
Kusalananda♦Kusalananda
141k17263439
141k17263439
Thanks for clarifying! BTWfind "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested
– z0lupka
Apr 9 at 13:23
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would befind "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, wherefalse
is used to prevent any action whenprune
succeeds (sorry for this invasion, Kusalananda).
– fra-san
Apr 9 at 13:34
add a comment |
Thanks for clarifying! BTWfind "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested
– z0lupka
Apr 9 at 13:23
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would befind "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, wherefalse
is used to prevent any action whenprune
succeeds (sorry for this invasion, Kusalananda).
– fra-san
Apr 9 at 13:34
Thanks for clarifying! BTW
find "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested– z0lupka
Apr 9 at 13:23
Thanks for clarifying! BTW
find "$HOME" -path "$HOME/sandboxes" -prune -type f -o -name 'some-file.vmdk'
helped too as @fra-san suggested– z0lupka
Apr 9 at 13:23
1
1
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would be
find "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, where false
is used to prevent any action when prune
succeeds (sorry for this invasion, Kusalananda).– fra-san
Apr 9 at 13:34
@z0lupka Please note that what I wrote in my previous comment is a bit ugly. Semantically, the correct form would be
find "$HOME" -path "$HOME/sandboxes" -prune -false -o -name 'some-file.vmdk'
, where false
is used to prevent any action when prune
succeeds (sorry for this invasion, Kusalananda).– fra-san
Apr 9 at 13:34
add a comment |
You can try this way :
find ~ ! -path "*/sandboxes/*" -name 'some-file.vmdk'
Or with -prune :
find ~ -path "*/sandboxes" -prune -o -name 'some-file.vmdk'
but can't find a way to remove the print of ~/sandboxes
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
add a comment |
You can try this way :
find ~ ! -path "*/sandboxes/*" -name 'some-file.vmdk'
Or with -prune :
find ~ -path "*/sandboxes" -prune -o -name 'some-file.vmdk'
but can't find a way to remove the print of ~/sandboxes
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
add a comment |
You can try this way :
find ~ ! -path "*/sandboxes/*" -name 'some-file.vmdk'
Or with -prune :
find ~ -path "*/sandboxes" -prune -o -name 'some-file.vmdk'
but can't find a way to remove the print of ~/sandboxes
You can try this way :
find ~ ! -path "*/sandboxes/*" -name 'some-file.vmdk'
Or with -prune :
find ~ -path "*/sandboxes" -prune -o -name 'some-file.vmdk'
but can't find a way to remove the print of ~/sandboxes
answered Apr 9 at 11:58
ctac_ctac_
1,4721211
1,4721211
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
add a comment |
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
unfortunately didn't help
– z0lupka
Apr 9 at 13:10
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%2f511416%2ffind-path-excluding-doesnt-work-when-permission-denied%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
Could you replace
-path "~/sandboxes/*"
with-path "$HOME/sandboxes/*"
– Inian
Apr 9 at 9:55
@Inian there is no effect. The same output
– z0lupka
Apr 9 at 10:01
Can you confirm you are you looking for regular files named
some-file.vmdk
only? It may be useful to state explicitly what the expected output is, we may wonder if you want the path/home/user/sandboxes
(not its content) to be printed or not.– fra-san
Apr 9 at 12:35
@fra-san Yep, it's about regular files it this case. I want
find
not to even enter/home/user/sandboxes
– z0lupka
Apr 9 at 13:29