Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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
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 '14 at 21:36

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

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:

share|improve this answer

man grep :-)

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .