I have a plan to use find
to give me a list of files that are older than some FILE and then use xargs
(or -exec
) to move the files to somewhere else. Moving stuff is not a problem; | xargs mv {} ~/trash
works fine.
Now, if I try to use ! -newer FILE
, then FILE
is included in the list, which I do not want!
The functionality of that command argument does indeed make sense logically, though, because 'not newer' could very well be interpreted as "same or older", like here:
$ find . ! -newer Selection_008.png -exec ls -l {} \;
includes the file from the compare argument:
-rw-r--r-- 1 and and 178058 2012-09-24 11:46 ./Selection_004.png
-rw-r--r-- 1 and and 16260 2012-09-21 11:25 ./Selection_003.png
-rw-r--r-- 1 and and 38329 2012-10-04 17:13 ./Selection_008.png
-rw-r--r-- 1 and and 177615 2012-09-24 11:53 ./Selection_005.png
(ls -l
is only to show dates for illustrative purposes)
What I really need from find
is an -older
option, but none is listed in find(1)
...
Of course, one could just pipe the output through grep -v
, use sed
, etc., or utilise an environment variable to reuse the filename (fx. for grep -v
) so I can enjoy the DRY-principle, like
$ COMP=Selection_008.png find . ! -newer $COMP | grep -v $COMP | xargs ...
but it just seems to be a lot of writing for a oneliner and that is not what I am looking for.
Is there a shorter/simpler way than find
or am I missing some option? I have checked the manpage, and searched Google and SO...