Re: arg list to long wnad while command

From: Frye, Matthew (Matthew.Frye@REXHEALTH.COM)
Date: Mon Mar 31 2003 - 09:39:12 EST


I would suggest tagging anything that comes after GROUP with a throwaway
variable. As in...

ls -ltr *.$EXTENSION 2>/dev/null | while read FILESTATUS NUMBER OWNER GROUP
junk

This may solve your problem given that the last variable in the line will
take whatever is left, as in this example.

/home/mfrye# ls -ltr *.*p*
-rwxr-xr-x 1 mfrye staff 2684 Nov 21 15:51 Oct.24.2002.prs
-rwxr--r-- 1 mfrye staff 192757 Jan 27 16:26
pdksh-5.2.14-16.i386.rpm
-rwxr--r-- 1 mfrye staff 197 Mar 11 10:33 grepper.pl

/home/mfrye# ls -ltr *.*p* | while read a b c ; do
> print "\$a is $a"
> print "\$b is $b"
> print "\$c is $c"
> done
$a is -rwxr-xr-x
$b is 1
$c is mfrye staff 2684 Nov 21 15:51 Oct.24.2002.prs
$a is -rwxr--r--
$b is 1
$c is mfrye staff 192757 Jan 27 16:26 pdksh-5.2.14-16.i386.rpm
$a is -rwxr--r--
$b is 1
$c is mfrye staff 197 Mar 11 10:33 grepper.pl

With the $junk variable, your last valid one gets assigned just what it is
supposed to. Just a possibility.

Matt Frye
Sr. Systems Programmer, RS/6000 Group
Rex Healthcare
(919) 784-3791

> ----------
> From: John Dunn[SMTP:john.dunn@SEFAS.CO.UK]
> Reply To: IBM AIX Discussion List
> Sent: Monday, March 17, 2003 5:50 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