Re: ls and while

From: Steven Langdale (Langdale_Steven@PERKINS.COM)
Date: Mon Mar 17 2003 - 09:18:37 EST


Hello

There are a couple of problems here:

1. The find is not displaying the same info as "ls -ltr"
2. Too much data is being processed by the xargs command. You want to do
one line at a time, "xargs -n1" is needed for that.

Here is an example of what you may want to do, it's probably inefficient,
but its similar to your original lines....

find . -name "*.*" | xargs ls -ltr |while read FILESTATUS NUMBER OWNER
GROUP
do
  echo $FILESTATUS" "$NUMBER
done

Thanks

Steven

                      John Dunn
                      <john.dunn@SEFAS To: aix-l@Princeton.EDU
                      .CO.UK> cc:
                      Sent by: IBM AIX
                      Discussion List
                      <aix-l@Princeton
                      .EDU> Subject: ls and while

                      03/17/2003 11:10
                      Please respond
                      to IBM AIX
                      Discussion List

Perkins: Confidential Green Retain Until: 04/16/2003 Retention Category:
                                                G90 - Information and
                                                Reports

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:40 EDT