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

Re: mv files by date



Curtis Vaughan wrote:
> Should I do this?
> 
> find ./ -type f ! -mtime -2 -exec ls -al {} \; | xargs mv ../

You can but you are doing it too much complicated -- find by default prints
on stdout found filename. And concerning xargs -- I don't use it that much
(it always confuses me to no end), but doesn't it put the filename from
stdin to END. So that effectively you would have

mv ../ filename

(I don't think, that's what you want).

I really prefer my while cycle:

find ./ -type f ! -mtime -2 | while read FILENAME
do mv $FILENAME somewhere/
done

Result is the same as with xargs, but at least I know what's going on.

Matej

-- 
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
http://www.ceplovi.cz/matej/blog/, Jabber: ceplma@jabber.cz
23 Marion St. #3, (617) 876-1259, ICQ 132822213
 
All parts should go together without forcing. You must remember
that the parts you are reassembling were disassembled by you.
Therefore, if you can't get them together again, there must be a
reason. By all means, do not use a hammer.
    -- IBM maintenance manual, 1925




Reply to: