[opensuse] find --prune problem
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 DONDE="/" LISTADO_FIND="encontrarscript_listado_ficheros" find "$DONDE" -type f \ -prune -o -path '/var/spool/news' \ -prune -o -path '/var/run/udev/links' \ -prune -o -path '/var/run/user' \ -prune -o -path '/var/run/systemd' \ -prune -o -path '/var/lib/ntp/proc' \ -prune -o -path '/proc' \ -prune -o -path '/sys' \ -prune -o -path '/run' \ -prune -o -path '/run/udev/links' \ -prune -o -path '/var/run/vmblock-fuse' \ -prune -o -path '/data/My_Book/Backup' \ -prune -o -path '/mnt/BookTelcontar' \ -prune -o -path '/data/waterhoard/backup' \ > $LISTADO_FIND Yet when it runs it spits: find: ‘/data/waterhoard/backup/partimag/AmonLanc/etc/apache2/ssl.key’: Permission denied find: ‘/data/waterhoard/backup/partimag/AmonLanc/etc/cups/ssl’: Permission denied find: ‘/data/waterhoard/backup/partimag/AmonLanc/etc/news’: Permission denied find: ‘/data/waterhoard/backup/partimag/AmonLanc/etc/polkit-1/rules.d’: Permission denied find: ‘/data/waterhoard/backup/partimag/AmonLanc/etc/ppp’: Permission denied So prune is not doing what I thought it would do. How can I tell find to not search those directories? - -- Cheers Carlos E. R. (from 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCXiIBCRwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVclcAnRU/YZBbAbIp+6E+5AZV eOVh6AFBAJ9Mi9i1/BtBFz8fb7yimW2YG6z9Rg== =itHc -----END PGP SIGNATURE-----
Hello, On Fri, 17 Jan 2020, Carlos E. R. wrote:
find "$DONDE" -type f \ -prune -o -path '/var/spool/news' \ [..] -prune -o -path '/data/waterhoard/backup' \ > $LISTADO_FIND
Yet when it runs it spits:
find: '/data/waterhoard/backup/partimag/AmonLanc/etc/apache2/ssl.key': Permission denied [..] So prune is not doing what I thought it would do. How can I tell find to not search those directories?
You're using it wrong! ;) ==== man find ==== EXPRESSION [..] An expression is composed of a sequence of things: Tests [..] Actions [..] [options] [Operators] [..] TESTS [..] -path pattern -type c [..] ACTIONS [..] -print [..] -prune [..] ==== So what you're doing is -pruning the matches for '-type f', then each following '-path' but not the last. Use this: ==== find "$DONDE" \ -path '/var/spool/news' -prune \ [..] -o -path '/data/waterhoard/backup' -prune \ -o -type f -print > "$LISTADO_FIND" ==== This is _slightly_ different from find "$DONDE" -type f -path '/var/spool/news' -prune \ [..] -o -path '/data/waterhoard/backup' -prune \ -o -print which probably is not what you're looking for. HTH, -dnh -- Why oh why did I remember that? Bad brain. Naughty brain. -- JoeB -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17/01/2020 20.23, David Haller wrote: | Hello, | | On Fri, 17 Jan 2020, Carlos E. R. wrote: |> find "$DONDE" -type f \ -prune -o -path '/var/spool/news' |> \ | [..] |> -prune -o -path '/data/waterhoard/backup' \ |>> $LISTADO_FIND |> |> Yet when it runs it spits: |> |> find: |> '/data/waterhoard/backup/partimag/AmonLanc/etc/apache2/ssl.key': |> Permission denied | [..] |> So prune is not doing what I thought it would do. How can I tell |> find to not search those directories? | | You're using it wrong! ;) I know I am, but not why, that's why I ask :-D | | ==== man find ==== EXPRESSION [..] An expression is composed of a | sequence of things: | | Tests [..] Actions [..] [options] [Operators] [..] TESTS [..] -path | pattern -type c [..] ACTIONS [..] -print [..] -prune [..] ==== | | So what you're doing is -pruning the matches for '-type f', then | each following '-path' but not the last. AHH! | | Use this: | | ==== find "$DONDE" \ -path '/var/spool/news' -prune \ | [..] -o -path '/data/waterhoard/backup' -prune \ -o -type f -print | > "$LISTADO_FIND" ==== I see. Indeed, it is different. | | This is _slightly_ different from | | find "$DONDE" -type f -path '/var/spool/news' -prune \ [..] -o | -path '/data/waterhoard/backup' -prune \ -o -print | | which probably is not what you're looking for. Thanks. Trying. [...] Seems to be working. Found 845143 files, way faster than previously (a minute or so). The next step in the script finds out which of those are bash scripts. That takes long :-) - -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCXiIONAAKCRC1MxgcbY1H 1SD8AJ9rz0wsc3krAqPqNwYvq1s8sh5iJwCeONZ/cvPvvTUKsnlbcVaF6RBlDmQ= =fCVt -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2020-01-17 20:42, Carlos E. R. wrote:
Seems to be working.
FWIW: often one knows that the search should stay on the current file system. Therefore, I often use -xdev or -mount. $ find / -xdev ! -type f -prune ... Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17/01/2020 21.55, Bernhard Voelker wrote: | On 2020-01-17 20:42, Carlos E. R. wrote: |> Seems to be working. | | FWIW: often one knows that the search should stay on the current | file system. Therefore, I often use -xdev or -mount. | | $ find / -xdev ! -type f -prune ... Yes, but it is not the case, I'm searching all disks except the backup directories. (still running, by the way) - -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCXiInxgAKCRC1MxgcbY1H 1ZIOAJ9u/dYHZN4kgX6nkVlfQCvlp4N0FACeNmSi1kCBkky3Lpw+g1KL+aOE7I4= =WB0T -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2020-01-17 22:32, Carlos E. R. wrote:
On 17/01/2020 21.55, Bernhard Voelker wrote: | On 2020-01-17 20:42, Carlos E. R. wrote: |> Seems to be working. | | FWIW: often one knows that the search should stay on the current | file system. Therefore, I often use -xdev or -mount. | | $ find / -xdev ! -type f -prune ...
Yes, but it is not the case, I'm searching all disks except the backup directories.
(still running, by the way)
Well, you know your mount points - you can pass them as arguments. ;-) $ find /home /data -xdev ... Re. the search for scripts: they are usually executable; and the search can probably also limited to files with a size < 100K. If you are sure you don't have strange file names, then this would do: $ find /home /data -xdev -type f -executable -size -100000c -exec file '{}' + | grep -i script Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17/01/2020 23.05, Bernhard Voelker wrote: | On 2020-01-17 22:32, Carlos E. R. wrote: |> On 17/01/2020 21.55, Bernhard Voelker wrote: | On 2020-01-17 |> 20:42, Carlos E. R. wrote: |> Seems to be working. | | FWIW: |> often one knows that the search should stay on the current | file |> system. Therefore, I often use -xdev or -mount. | | $ find / |> -xdev ! -type f -prune ... |> |> Yes, but it is not the case, I'm searching all disks except the |> backup directories. |> |> (still running, by the way) | | Well, you know your mount points - you can pass them as arguments. | ;-) | | $ find /home /data -xdev ... Just all the disks, which is easier. In any case, I have to avoid some paths on some disks. | | Re. the search for scripts: they are usually executable; Not always. I intentionally do not mark all of them executable in order to not run them accidentally by clicking on them (or with 'mc'). I have to run them via "bash ./something" | and the search can probably also limited to files with a size < | 100K. | | If you are sure you don't have strange file names, then this would | do: | | $ find /home /data -xdev -type f -executable -size -100000c -exec | file '{}' + | grep -i script I do have a working method, it was the initial find which was not going right. The problem is solved. Maybe can be improved. The size limit is a good point. Initially, it was one liner: find ~/bin -type f -print0 | xargs -0 file | \ ~ awk '/Bourne-Again/{print $1}' | tr -d ':' | \ ~ xargs -r grep -D skip string | less -S Currently it is, once I produce the list of all files in $LISTADO_FIND: while read FILES ; do ~ if [ -f "$FILES" -a -s "$FILES" ]; then ~ TIPO=`head -c 1000 "$FILES" | file - | grep Bourne-Again` ~ if [ $? -eq 0 ]; then ~ echo "$FILES" >> $LISTADO_SCRIPTS ~ fi ~ fi done < $LISTADO_FIND It has found 611, and then found 8 that match a search pattern. All in 136 minutes, much less than the original one line. - -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCXiI3AwAKCRC1MxgcbY1H 1dX+AJwMeZh6mKQFYBPKT62oUG60x8yl1QCfU3gfVmq5kYct52gXXs5Y67mGqwU= =x7VK -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Bernhard Voelker
-
Carlos E. R.
-
David Haller