• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Is there some more powerful version of GREP?

gopunk

Lifer
i get these messages saying "Arg list too long". is there another command i can use that will do the same thing? what is the restriction that is being run into here?
 
What are you typing exactly? It sounds like a syntax problem to me - like something that you want as an option is being seen as an argument instead.
 
Heh, sounds like you are trying to grep a few pages of strings as a pattern. What are you trying to do?
 
i am typing grep string */.subscribers

what is going on is i support listproc, a list server. we have thousands of lists. i wanted to see all the lists someone was subscribed to. so i typed in that command to search the .subscribers file of all the lists.
 
I'm not a *nix guru, but I suspect the shell is globbing too many filenames (the shell has a limit). Try the following (and let us know if it works):

find . -name ".subscribers" | xargs grep myPattern

where . is the working directory, or alternatively any directory where you want to start the recursion.
 
Your problem is the *.

What do you think * will be translated to? It will be translated to every directory[/subdirectory. . . ]/.subscribers from your current location, thus causing a possible infinite loop if it happens to encounter a link that traces back. For that reason, it is not permitted by grep. And, because it can also cause an overflow with a huge argument.
what you may want to do is use grep with the find command like this:

find <path_to_search_from> -type f -name ".subscribers" -exec grep "<your_pattern>" {} \; -print

Regular expressions are you friend, but when you don't know how to use them, they can cause headaches. . . 😉

GL

/edit: fixed typo
/edit: \"
 
thanks for the info lnxman, the find command works great 🙂

question though, are you sure grep doesn't permit *? because i can run grep string EEP*/.subscribers, and it will bring up a list of all the lists that begin with EEP, that have the string subscribed to it...
 
The shell does the globbing (wildcard expansion); it just passes in all the actual filenames to grep.

So, if you wanted to use a regular expression for the match pattern, you'd have to exclose it in quotes or else the shell would try to expand it.

By the time the shell has done the globbing, grep has no knowledge of the original wildcard expression. Like I said, if you're talking about hundreds or thousands of files, the shell has a limit.

LNXman is correct that a single find command is the solution; but I can never remember the syntax (it's kinda ugly) so I just pipe to xargs. It works, AFAIK.

Finally,

man find
man grep

🙂
 


<< thanks for the info lnxman, the find command works great 🙂

question though, are you sure grep doesn't permit *? because i can run grep string EEP*/.subscribers, and it will bring up a list of all the lists that begin with EEP, that have the string subscribed to it...
>>



Your above command is fine, just notice that you are giving it a start pattern (EEP) and then a regular expression. That is fine, because the EPP limits the amount of args to be used by grep (from the shell) to those which only start with EPP,
whereas if you just use the * by itself, you are using ANYTHING, and EVERYTHING to grep your string (from the shell), which is a "NO, NO!"

You may want to research on the differences between regular expressions from a CLI, and apps with regexp capabilities.
Homework for you:
Do a man to understand the differences in regular expressions between:
grep (HINT: regular expressions translated by CLI)
egrep (HINT: regular expressions translated by egrep)

NOTE: egrep is the same as grep -e <regexp>.

/edit: Added note
 
Back
Top