Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been happily using grep for many years without any issues, but since today it quit working. During the past hour I tried this and that, but enough is enough, I'm posting the bastard here:

On the simplest command like

grep 'aaa' file.txt

I'm getting this: grep: aaa: No such file or directory

So grep does not interpret the first argument as the pattern as it should, but treats it as a path.

Please help me, I'm going crazy '-(

share|improve this question

migrated from stackoverflow.com Aug 17 '10 at 15:33

This question came from our site for professional and enthusiast programmers.

    
run which grep and and make sure you are running the grep you think you are. –  Doon Aug 17 '10 at 15:24
    
$ /usr/bin/grep 'aaa' libiconv.log yields grep: aaa: No such file or directory And $ ls -al /usr/bin/grep yields -rwxr-xr-x 1 root wheel 225088 May 18 2009 /usr/bin/grep –  ak Aug 17 '10 at 15:27
    
Works fine here. You might want to include your Mac OS version in the question. –  zneak Aug 17 '10 at 15:28
    
In any case, this isn't a programming question. Voting to migrate to Super User. –  David Thornley Aug 17 '10 at 15:30
    
10.6.4 Are you saying that /usr/bin/grep 'export' ~/profile will return a meaningful result on your machine? –  ak Aug 17 '10 at 15:30
show 2 more comments

4 Answers

up vote 6 down vote accepted

I had something like this in my ~/.profile:

export GREP_OPTIONS='--color=always'

But with wrong syntax. Some malformeed argument was being passed to the grep breaking everything down. Removing the line resolved the problem.

share|improve this answer
    
thanks, i was going crazy too. i wonder if we all copied it from the same place –  rwilson04 May 29 at 21:36
add comment

You may have an alias set up for grep . An example:

$ grep aaa qq.s

$ alias grep='grep zzz'

$ grep aaa qq.s
grep: aaa: No such file or directory
share|improve this answer
    
$ alias does not return anything –  ak0 Aug 17 '10 at 15:35
add comment

I had the same issue. If you change the single quote to a double quote in your .bash_profile GREP_OPTIONS line, you will resolve the issue. This works:

 export GREP_OPTIONS="--color=auto"

The same export with single quotes does not work. This has to do with the way that bash interprets single quotes vs double quotes. This may provide additional guidance: http://www.gnu.org/software/bash/manual/bashref.html#Double-Quotes

share|improve this answer
add comment

man grep :-)

http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/grep.1.html

share|improve this answer
    
could you please point me to the section that would explain this behavior? –  ak0 Aug 17 '10 at 15:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.