The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Arg List too Long in SCP chris1234 UNIX for Dummies Questions & Answers 5 02-27-2008 04:40 AM
ksh: /usr/bin/ls: arg list too long jitindrabappa UNIX for Dummies Questions & Answers 2 10-12-2006 12:08 AM
ls -t arg list too long CSU_Ram UNIX for Dummies Questions & Answers 4 05-05-2005 07:19 AM
Parameter List to Long lesstjm Shell Programming and Scripting 3 03-07-2002 05:36 AM
arg list too long vingupta UNIX for Dummies Questions & Answers 5 08-02-2001 08:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
arg list too long

Does anyone have a solution for arg list too long error.
I have got this from the web but I fail to make any sense out of it
Quote:
The system could not handle the number of arguments given to a
command or program when it combined those arguments with the
environment's exported shell variables. The argument list limit
is the size of the argument list plus the size of the
environment's exported shell variables.

The easiest solution is to reduce the size of the parent process
environment by unsetting extraneous environment variables. (See
the man page for the shell you're using to find out how to list
and change your environment variables.) Then run the program
again.

An argument list longer than ARG_MAX bytes was presented to a
member of the exec() family of system calls.

The symbolic name for this error is E2BIG, errno=7.
Thanks
enc
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-26-2004
TioTony's Avatar
Bit Pusher
 

Join Date: Oct 2001
Location: Southern California
Posts: 332
Check out the xargs command. Can you post the command that is failing?
Reply With Quote
  #3 (permalink)  
Old 10-27-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
I have a dirctory(in fact many directories) for which I have to grep
a certain string -In my case a 10 digit number starting with 011
code:
Quote:
dirs=`ls`
for dir in $dirs
do
cd $dir
grep '^011.......$' *| cut -f1 -d :
done
For directories having a lot many files it says
/usr/bin/grep Arg list too long

Would find command help me?
find . -name * -exec egrep '^011......$' /dev/null {} \;

Thanks
enc
Reply With Quote
  #4 (permalink)  
Old 10-27-2004
TioTony's Avatar
Bit Pusher
 

Join Date: Oct 2001
Location: Southern California
Posts: 332
I think the find syntax as you have it will have the same problem. If you use xargs like this you may have some luck. I am not anywhere I can test it right now to confirm for you but this syntax may work:

find ./ -print | xargs grep '^011.......$' *| cut -f1 -d :

If you run this from your top level directory where you were running your script, you should get the results you want.
Reply With Quote
  #5 (permalink)  
Old 10-29-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
Quote:
find ./ -print | xargs grep '^011.......$' *| cut -f1 -d :
Gives the output while searching in a single directory:
xargs: a single arg was greater than max argsize of 2048 characters

Any Ideas??
enc
Reply With Quote
  #6 (permalink)  
Old 10-29-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Drop the "*" from the grep,

find ./ -print | xargs grep -l '^011.......$'

You also won't need the cut, use -l (ell) to grep to print the matching filenames.

Cheers
ZB
Reply With Quote
  #7 (permalink)  
Old 10-30-2004
encrypted's Avatar
Registered User
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 218
Thanks jazzybob you saved my day!!
But I was wondering why

find ./ -print | xargs grep '^011.......$' *| cut -f1 -d :

did not work in the first place.

Chill
enc
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0