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

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,724