Walt Mankowski on 15 Apr 2014 18:43:04 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] "find" command troubles |
On Tue, Apr 15, 2014 at 03:33:57PM -0400, JP Vossen wrote: > 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 You could also avoid that -exec part by using xargs(1) with something like this: find /mnt/backup/ -type f -mtime "+3" | xargs ls -l
Attachment:
signature.asc
Description: Digital signature
___________________________________________________________________________ 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