GNU userland: awk, grep, sed

Can I use the GNU userland such as awk, grep and sed in my shell? I just want to type grep and use it with the -r and -q flags. Right now, I get:

$ grep -q joe /etc/passwd
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .

Can I change this so I can successfully use grep as above?

asked: 2012-02-09 by: automaciej

pfelecan answers:

Put /opt/csw/gnu in your PATH environment variable, preferably before /usr/bin.

However, when using GNU userland, I prefer to explicitly use the specific g prefix, e.g. ggrep for GNU grep.

AirOnSkin commented:

I usually define aliases in my .bashrc That way you don't need to change system files and each user can decide for themselves if they want to use the Solaris binaries or the GNU ones

alias grep='ggrep'
alias tar='gtar'
alias sed='gsed'
alias awk='gawk'