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 aregrepping all those lines whose name ends withsafeand avoidinggrepitself to be part of the output.The thing here is that if you run the
pscommand andgrepits output, thegrepitself will be listed:So by saying
grep safe\$, or its equivalentgrep "safe$", you are adding a regular expression in the match that will make thegrepitself to not show.As a funny situation, if you use the
-Foption ingrep, it will match exact string, so the only output you will get is thegrepitself: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".