I'm using Mac OS X v10.9.1 (Mavericks). Occasionally in my terminal, I will run grep commands like:

grep -i -s 'mystring' *

Is there a way I can make the "-s" (--no-messages) option the default whenever I run grep?

1 Answer 1


You can set up an alias to replace grep with grep -s. This would be in somewhere like ~/.bashrc in the form alias grep='grep -s'.

  • I don't have a ~/.bashrc file, but I do have a ~/.profile file. However adding the line "alias grep=grep -s" resulted in a "-bash: alias: -s: not found" error when I exited and re-entered my terminal.
    – Dave
    Mar 14, 2014 at 16:31
  • Sorry, I missed the quotes above. (Should be alias grep='grep -s')
    – Holloway
    Mar 14, 2014 at 16:36
  • Thanks, I put that in, restarted my terminal, but running a command like "find ~/workspace/myproject/ -name "*" | xargs grep 'mytoken'" still results in "grep: /Users/davea/workspace/myproject/subdir/: Is a directory" messages. (If I manually add the "-s" to the command those messages go away.)
    – Dave
    Mar 14, 2014 at 17:00
  • Don't use xargs. It works for me anyway
    – Holloway
    Mar 14, 2014 at 20:28
  • When I remove xargs those messages go away.
    – Dave
    Mar 17, 2014 at 16:08

You must log in to answer this question.

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