Yes, it is a regex. $ is a regex character that means "end of line". So by saying grep safe\$ you are grepping all those lines whose name ends with safe and avoiding grep itself to be part of the output.
The thing here is that if you run the ps command and grep its output, the grep itself will be listed:
The typical trick to do this is grep -v grep, but you can find others in More elegant "ps aux | grep -v grep". I like the one that says ps -ef | grep "[b]ash".
Yes, it is a regex.
$
is a regex character that means "end of line". So by sayinggrep safe\$
you aregrep
ping all those lines whose name ends withsafe
and avoidinggrep
itself to be part of the output.The thing here is that if you run the
ps
command andgrep
its output, thegrep
itself will be listed:So by saying
grep safe\$
, or its equivalentgrep "safe$"
, you are adding a regular expression in the match that will make thegrep
itself to not show.As a funny situation, if you use the
-F
option ingrep
, it will match exact string, so the only output you will get is thegrep
itself:The typical trick to do this is
grep -v grep
, but you can find others in More elegant "ps aux | grep -v grep". I like the one that saysps -ef | grep "[b]ash"
.