Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 added 58 characters in body
source | link

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. It

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, so it would still give you the permission errors even when you used an unquoted ~ or $HOMEit 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.

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. 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, so it would still give you the permission errors even when you used an unquoted ~ or $HOME.

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.

2 added 87 characters in body
source | link

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/user"$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.

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. 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, so it would still give you the permission errors even when you used an unquoted ~ or $HOME.

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 ~ -path "/home/user/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.

Note that the * is not needed.


Your first command,

find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'

very likely does not work as ~ is not expanded within quotes. 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, so it would still give you the permission errors even when you used an unquoted ~ or $HOME.

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.

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. 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, so it would still give you the permission errors even when you used an unquoted ~ or $HOME.

1
source | link

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 ~ -path "/home/user/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.

Note that the * is not needed.


Your first command,

find ~ -not -path "~/sandboxes/*" -name 'some-file.vmdk'

very likely does not work as ~ is not expanded within quotes. 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, so it would still give you the permission errors even when you used an unquoted ~ or $HOME.