Re: rag list to long wand while command

From: Jef Lee (jef.lee@ITVISION.COM.AU)
Date: Mon Mar 31 2003 - 20:04:13 EST


John, I have experienced the "arg list too long" problem. It is a shell
constraint.

After several failed solutions, I found the workable solution to be breaking
up the file list. You need to determine some characteristics about the
files you are checking and use this to segregate the files into two or more
groups.

EG: If you files have filenames that are alphabetic, try -

for LEAD in '[a-m]' '[n-z]'
do
    ls -ltr ${LEAD}*.${EXTENSION} 2>/dev/null | while read FILESTATUS NUMBER
OWNER GROUP DUMMY
    do
        do_something_with_data
    done
done

Jef.....

> -----Original Message-----
> From: John Dunn [mailto:john.dunn@SEFAS.CO.UK]
> Sent: March 17, 2003 5:51 AM
> To: aix-l@Princeton.EDU
> Subject: arg list to long wnad while command
>
>
> I currently have a script that does the following
>
>
>
> ls -ltr *.$EXTENSION 2>/dev/null | while read FILESTATUS
> NUMBER OWNER
> GROUP
>
> do
>
> something
>
> done
>
>
> I am hitting the arg list too long problem on the ls command
> when there are
> a long list of files
>
> I have tried replacing ls with find but get an error that "do
> is unexpected"
>
> find . -name '*.$EXTENSION' | xargs while read FILESTATUS
> NUMBER OWNER
> GROUP
>
>
> Can anyone help with the syntax required, please
>
> John
>



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:42 EDT