| JP Vossen on 15 Apr 2014 12:34:03 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [PLUG] "find" command troubles |
On 04/15/2014 02:52 PM, brent timothy saner wrote: [...]
You can leave off the "-exec ls" part if you just want a list. :)
(you can also do -exec ls -l '{}' \; to repeat your two steps into one)
[...]
find /mnt/backup/ -type f -mtime "+3" [-exec ls -l '{}' \;]
The stuff in [] is optional, of course. (leave out the [] if you
actually want to include it)
Depending on your goal you may want to avoid using -exec if you can, since IIRC it will basically spawn a sub-shell per iteration. That can quickly become a lot of overhead if you 'find' a lot of files. OTOH, that can also be exactly what you need if you need to process them one at a time or something. YMMV.
If all you want is 'ls -l' sort of output, look at the find "-ls" option, which is not the same format, but... If you require either 'ls -l' or some other specific format, look at 'find ... -printf' and build your own. Like:
# "CCYY-MM-DD HH:MM {tab} size {tab} path" sorted by path:
find . -type f -printf '%TY-%Tm-%Td %TH:%TM\t%s\t%p\n' \
| sort -t' ' -k3,3
Later,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP |:::======| http://bashcookbook.com/
My Account, My Opinions |=========| http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug