Re: find with -print0 returns incorrect results

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

 



Tony Nelson wrote:
At 2:27 PM +0200 12/8/07, Razvan RACASANU wrote:
Hi,

I'm having some problems using find with -print0: it is returning
different files depending on the position of -print0.

To illustrate this, suppose the current directory has 3 files: a.html,
a.css and a.js. From this directory I would like to list the file
names of all html and js files, but not those of css files.

If I try this:
   find . -type f -print0 -iname "*.html" -or -iname "*.js" | xargs -0
the result looks like this:
   ./a.html        ./a.js        ./a.css

If I try this:
   find . -print0 -type f -iname "*.html" -or -iname "*.js" | xargs -0
the result looks like this:
   .        ./a.html        ./a.css

If I try this:
   find . -type f -iname "*.html" -or -iname "*.js" -print0 | xargs -0
the result looks like this:
   ./a.js

Can anybody shed some light on what am I doing wrong?

Conditions in find that aren't joined with an explicit operation are joined
with an implicit "and", so you effectively had '\( -type f -and -iname
"*.html" \) -or -iname "*.js"', where the first -iname was bound to -type
by the implicit -and and operator precedence.
Not quite. from 'man find'
-print True; print the full file name on the standard output, followed by a newline.

       -print0
True; print the full file name on the standard output, followed by a null character. This allows file names that contain newlines to be correctly interpreted by programs that process the find out-
              put.



--

Cheers
John

-- spambait
1aaaaaaa@xxxxxxxxxxxxxxxx  Z1aaaaaaa@xxxxxxxxxxxxxxxx
-- Advice
http://webfoot.com/advice/email.top.php
http://www.catb.org/~esr/faqs/smart-questions.html
http://support.microsoft.com/kb/555375

You cannot reply off-list:-)

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux