1752797 Members
5818 Online
108789 Solutions
New Discussion юеВ

can't grep file

 
ust3
Regular Advisor

can't grep file

when I use grep , it pop the below message ,

"bash: /bin/grep: Argument list too long"

I know this is because there are too many files in directory, except use the command "find" , how to fix it ? is it because the memory is not enough to list all files ? if yes , how to change the parameter to increase the memory ? thx
4 REPLIES 4
Jeeshan
Honored Contributor

Re: can't grep file

did u try ll|grep argument?
a warrior never quits
ust3
Regular Advisor

Re: can't grep file

thx reply ,

this error not only happen when use grep , sometimes it happens when I use ls , ll etc, so is there any method to fix it ? thx
Stoner
New Member

Re: can't grep file

As far as i know there are no memory-settings you can change to make it work.

What i do is to use find to reduce the numbers of files to work on.
Ex:
find . -name 'filename*' -exec grep text {} \;

this would search for text in all files starting with filename in the current directory.
Her you can combine the different arguments for find like mtime ctime etc etc..
Nobody told me it couldn't be done
Ivan Ferreira
Honored Contributor

Re: can't grep file

This happens when you have too many files in your directory. You can't avoid this. Use find and xargs commands to solve your problem.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?