On Wed, Oct 20, 2010 at 3:06 PM, Kai Hendry <hen...@iki.fi> wrote: > I have a script that uses find and -newer, however everytime it's > invoked it returns the same selected old results. For the most part it > works, but for example the particular old contents of > "/home/hendry/static.natalian.org/2009-01-05/" are returned. How can > this be explained? > > Many thanks, > > > thor:456$ find /home/hendry/static.natalian.org -newer last.txt -iname > *.ogg -o -iname *.ogv -type f
This is a valid find command line. But there are two problems with it that mean it no doubt does not do what you hoped. 1. You did not quote the arguments to -iname. See for example the section NON-BUGS in the find manpage. Also see the description of -iname in the same manual page. 2. The precedence of the implicit "and" between tests is higher than that of "-o". See the section OPERATORS in the find manpage. In other words find /home/hendry/static.natalian.org -newer last.txt -iname "*.ogg" -o -iname "*.ogv" -type f means the same as find /home/hendry/static.natalian.org \( -newer last.txt -iname "*.ogg" \) -o \( -iname "*.ogv" -type f \) not the same as find /home/hendry/static.natalian.org -newer last.txt \( -iname "*.ogg" -o -iname "*.ogv" \) -type f ... whereas it is probably the latter (with the altered -type f) that you intended. I hope this helps, James. > /home/hendry/static.natalian.org/2010-01-10/12.ogv > /home/hendry/static.natalian.org/2010-01-10/11.ogv > /home/hendry/static.natalian.org/2010-01-10/23.ogv > /home/hendry/static.natalian.org/2010-01-10/24.ogv > /home/hendry/static.natalian.org/2010-01-10/22.ogv > /home/hendry/static.natalian.org/2010-01-10/33.ogv > /home/hendry/static.natalian.org/2010-01-10/32.ogv > /home/hendry/static.natalian.org/2010-01-10/21.ogv > /home/hendry/static.natalian.org/2010-01-10/31.ogv > /home/hendry/static.natalian.org/2010-01-10/13.ogv > /home/hendry/static.natalian.org/2010-01-10/34.ogv > /home/hendry/static.natalian.org/2009-07-12/talkaoke-2009-05-28-host_session_9-part_2.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4205.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3967.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4206.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4169.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3969.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4160.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4217.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_4183.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3949.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3970.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3966.ogv > /home/hendry/static.natalian.org/2009-01-05/mvi_3968.ogv > thor:457$ cat last.txt > /home/hendry/static.natalian.org/2010-01-10/34.ogv > > thor:459$ stat /home/hendry/static.natalian.org/2009-01-05/mvi_4205.ogv > File: `/home/hendry/static.natalian.org/2009-01-05/mvi_4205.ogv' > Size: 3161219 Blocks: 6184 IO Block: 4096 regular file > Device: 811h/2065d Inode: 187843284 Links: 1 > Access: (0644/-rw-r--r--) Uid: (67299/ hendry) Gid: (24839/pg224602) > Access: 2009-07-17 17:45:50.000000000 -0700 > Modify: 2009-01-05 05:41:32.000000000 -0800 > Change: 2009-07-23 06:57:19.000000000 -0700 > thor:460$ stat last.txt > File: `last.txt' > Size: 51 Blocks: 8 IO Block: 4096 regular file > Device: 811h/2065d Inode: 187260985 Links: 1 > Access: (0664/-rw-rw-r--) Uid: (67299/ hendry) Gid: (24839/pg224602) > Access: 2010-03-08 01:07:08.000000000 -0800 > Modify: 2010-10-20 06:56:42.000000000 -0700 > Change: 2010-10-20 06:56:42.000000000 -0700 > thor:461$ stat /home/hendry/static.natalian.org/2009-01-05 > File: `/home/hendry/static.natalian.org/2009-01-05' > Size: 4096 Blocks: 8 IO Block: 4096 directory > Device: 811h/2065d Inode: 187842583 Links: 2 > Access: (0755/drwxr-xr-x) Uid: (67299/ hendry) Gid: (24839/pg224602) > Access: 2009-07-17 18:06:41.000000000 -0700 > Modify: 2009-01-05 05:41:32.000000000 -0800 > Change: 2009-07-23 06:57:19.000000000 -0700 > > > > thor:463$ mount > /dev/sda1 on / type ext3 (rw,errors=remount-ro) > tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) > proc on /proc type proc (rw,noexec,nosuid,nodev) > sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) > tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) > devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) > /dev/sda2 on /tmp type ext3 > (rw,noexec,noatime,nodiratime,data=ordered,commit=300) > /dev/sda6 on /var/spool/cron/crontabs type ext3 (rw,nosuid,nodev) > /dev/sdb1 on /home type ext3 > (rw,nosuid,nodev,noatime,nodiratime,errors=remount-ro,data=writeback) > none on /sys/kernel/config type configfs (rw) > >