Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ls question

Status
Not open for further replies.

kathi

Programmer
Joined
Jun 17, 2002
Messages
9
Location
GB
I have a script which involves an ls on a directory which contains files derived from an external source. All works fine, but VERY occasionally we get a massive number of files and the ls throws the following error:

/usr/bin/ls: 0403-027 The parameter list is too long.

Is there anything I can do to stop that ? We're running AIX 4 on an RS/6000. Last night we got almost 13000 files!
 
You could try using the find command instead and outputting to a file??

ie. instead of ls /directory
use find /directory > filelist

Then it will just create a big file!

ChrisCW

** Helen Waite is now in charge of all rush orders. If you are in a hurry, just go to Helen Waite.
 
Thanks.

I got round this in the end by using find, but that gave me the whole directory listing too. Eventually stripped this out using basename.

Original code:

for usename in `ls pbe_rep*.txt`
do

Replaced by:

for usename in `find $LOCATION -name "pbe_rep*.txt"`
do
usename=`basename $usename`
 
Use the find command:

find . -print | xargs ls -ld >/tmp/list_of_files

--
| Mike Nixon
| Unix Admin
| ----------------------------
 
or:
for file in `ls or find whatouwant`
do ....
done
the shell has limits 1024 ot 2048 params
depending yous OS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top