[Dclug] Recursively listing files by some category

David Turvene dturvene at comcast.net
Wed May 21 12:49:36 EDT 2008


On Wed, 2008-05-21 at 04:23 -0700, Gururajan Ramachandran wrote:

> Hello,
> 
> A line such as:
> 
> find . -type f -print | xargs -n 600000 ls -lart
> 
> works upto a certain point. At some point something
> like this runs out of shell buffer space if the number
> of files and directories are large enough.
> 
> Are there any utilities that can recursively list
> files sorted by some category (date or size or etc...)
> irrelevant of the number of files?
> 
> Thanks,


Well, it certainly seems like a buffer exhaustion problem but are you
sure?  What is the error code?  I'm guessing 123 - which could mean a
number of things.

There are many solutions to get around the common problem (which means
Google is your friend) of shell buffer limits .  Have you experimented
with the find "-exec" option?  Perl or Python scripts are great
solutions, and fairly efficient.  Maybe do several find commands, each
on a different directory branch?  Here's a simple, but very slow, bash
script.

#! /bin/bash

cmdfunc() {

    FINDOUT=/tmp/find.out
    CMDOUT=/tmp/cmd.out

    rm -f $CMDOUT

    find . -type f > $FINDOUT
    exec < $FINDOUT
    while read filename; do
      ls -lart $filename >> $CMDOUT
    done
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://calypso.tux.org/pipermail/dclug/attachments/20080521/1f752c60/attachment-0033.html 


More information about the Dclug mailing list