bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #54730] Add additional valuable example of find -quit


From: Bernhard Voelker
Subject: [bug #54730] Add additional valuable example of find -quit
Date: Wed, 26 Sep 2018 02:33:11 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #1, bug #54730 (project findutils):

I'm not sure what you want to achieve with the perl example,
because there is a syntax error in it - probably due to missing
quoting.

Here's another example:

For each file in '/dev', run stat(1) to print its file type and name,
and stop at the first block device found:

 $ find /dev \
     -exec stat -c "%F: %n" '{}' \; \
     \( -exec test ! -b '{}' \; -o -quit \)
  directory: /dev
  character special file: /dev/vcsa10
  character special file: /dev/vcs10
  fifo: /dev/xconsole
  character special file: /dev/vcs2
  block special file: /dev/loop7

This example is more complex than the one in the man page.
Maybe we should expand on the man page by saying that find stops at
the first existing file:

  # Prepare files 3 4 5, ensuring that 1 and 2 do not exist.  
  $ rm -f 1 2 ; touch 3 4 5

  # Run find to print the file name of and stop at the first existing one.
  $ find 1 2 3 4 5 -print -quit
  find: '1': No such file or directory
  find: '2': No such file or directory
  3

Do you mean something like that?  Or what real-life example would
you prefer?


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54730>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]