arg list too long | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

arg list too long

UNIX for Advanced & Expert Users


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-26-2004
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
 
Join Date: Feb 2004
Last Activity: 30 November 2011, 9:36 AM EST
Location: Oslo, Norway
Posts: 220
Thanks: 0
Thanked 1 Time in 1 Post
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
Sponsored Links
    #2  
Old 10-26-2004
TioTony's Avatar
TioTony TioTony is offline Forum Advisor  
Bit Pusher
 
Join Date: Oct 2001
Last Activity: 6 April 2014, 6:16 PM EDT
Location: Southern California
Posts: 332
Thanks: 0
Thanked 1 Time in 1 Post
Check out the xargs command. Can you post the command that is failing?
Sponsored Links
    #3  
Old 10-27-2004
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
 
Join Date: Feb 2004
Last Activity: 30 November 2011, 9:36 AM EST
Location: Oslo, Norway
Posts: 220
Thanks: 0
Thanked 1 Time in 1 Post
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
    #4  
Old 10-27-2004
TioTony's Avatar
TioTony TioTony is offline Forum Advisor  
Bit Pusher
 
Join Date: Oct 2001
Last Activity: 6 April 2014, 6:16 PM EDT
Location: Southern California
Posts: 332
Thanks: 0
Thanked 1 Time in 1 Post
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.
Sponsored Links
    #5  
Old 10-29-2004
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
 
Join Date: Feb 2004
Last Activity: 30 November 2011, 9:36 AM EST
Location: Oslo, Norway
Posts: 220
Thanks: 0
Thanked 1 Time in 1 Post
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
Sponsored Links
    #6  
Old 10-29-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
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
Sponsored Links
    #7  
Old 10-30-2004
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
 
Join Date: Feb 2004
Last Activity: 30 November 2011, 9:36 AM EST
Location: Oslo, Norway
Posts: 220
Thanks: 0
Thanked 1 Time in 1 Post
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
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



All times are GMT -4. The time now is 06:29 PM.