0

I am searching for the executable file name pxe using the command

find / -type f -executable -print | grep pxe$

and this works fine in RHEL, but in SLES the snapshot directory messses up the search. How to exclude the snapshot directory in my search.

I have tried these combination but did work.

localhost:~ # find / -type f -executable -print | grep pxe$
find: File system loop detected; ‘/.snapshots/1/snapshot’ is part of the same file system loop as ‘/’.
/root/pxe
/root/xyx/pxe
/pxe
localhost:~ # find / -type f -executable -print -not -path "*/.snapshots/*" | grep pxe$
find: File system loop detected; ‘/.snapshots/1/snapshot’ is part of the same file system loop as ‘/’.
/root/pxe
/root/xyx/pxe
/pxe
localhost:~ #
localhost:~ #
localhost:~ # find / -type f -executable -print -not -path "/.snapshots/*" | grep pxe$
find: File system loop detected; ‘/.snapshots/1/snapshot’ is part of the same file system loop as ‘/’.
/root/pxe
/root/xyx/pxe
/pxe

I do not want the /.snapshots/ to show up when find is run. Any suggestion?

snapshot dir is under /

test:~ # cd /
test:/ # ls -la
total 52588
drwxr-xr-x    1 root root      224 Apr  6 16:28 .
drwxr-xr-x    1 root root      224 Apr  6 16:28 ..
-rw-r--r--    1 root root        0 Mar 30 15:03 .acce
drwxr-x---    1 root root       38 Mar 20 12:25 .snapshots
-rwxrwxrwx    1 root root 26559432 Oct 14 12:23 pxe
redpy
  • 3
  • 2

1 Answers1

0

As with all things Linux, man should be your first stop, it's usually just a matter of finding the term that matches what you're looking for. man find and /skip yields:

-prune

True; if the file is a directory, do not descend into it. If -depth is given, then -prune has no effect. Because -delete implies -depth, you cannot usefully use -prune and -delete together. For example, to skip the directory src/emacs and all files and directories under it, and print the names of the other files found, do something like this:

find . -path ./src/emacs -prune -o -print

Ginnungagap
  • 2,595
  • 10
  • 13
  • thanks! Had a followup: find bar -path /foo/bar/myfile -print Find compares the -path argument with the concatenation of a directory name and the base name of the file it's examining. Since the concatenation will never end with a slash, -path arguments ending in a slash will match nothing (except perhaps a start point specified on the command line). compares -> /foo/bar/myfile with Concatenation of -> /foo/bar/myfile/ + myfile = /foo/bar/myfile/myflile "since... ends .. slash" -> When I try to concatenate as above I do not see an ending slash? – redpy Apr 12 '23 at 00:35
  • Are you wondering why the underlying logic of the `-path` filter isn't shown in the resulting output? Or am I misunderstanding? If not I'd suggest asking a new question with good examples of what you're running, what you're getting, what you're expecting and why. – Ginnungagap Apr 12 '23 at 16:27
  • edited my question to original state. Hope someone find the answer to a question similar to mine. Thanks for (find . -path /.snapshots -prune -o -print) This totally works and solves my issue. Will have a different post for my other question on (man find) makes it easier. Thanks again. MY Question is answered!! – redpy Apr 13 '23 at 02:03