When the shell itself filters the output of ps, then removing a grep is unnecessary. Note this uses POSIX shell patterns, not regular expressions.
On a truly POSIX shell that does not support "local," remove the keyword, and change the braces to parentheses to force the function into a subshell.
pps () { local a= b= c= IFS='\0'; ps ax | while read a do [ "$b" ] || c=1; for b; do case "$a" in *"$b"*) c=1;; esac; done; [ "$c" ] && printf '%s\n' "$a" && c=; done; } $ pps systemd PID TTY STAT TIME COMMAND 1 ? Ss 5:11 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 557 ? Ss 0:19 /usr/lib/systemd/systemd-journald ...
You almost always want "read -r": https://github.com/koalaman/shellcheck/wiki/SC2162
pps () { local a= b= c= IFS=$'\0'; ps ax | while read -r a do [ "$b" ] || c=1; for b; do case "$a" in *"$b"*) c=1;; esac; done; [ "$c" ] && printf '%s\n' "$a" && c=; done; }
When the shell itself filters the output of ps, then removing a grep is unnecessary. Note this uses POSIX shell patterns, not regular expressions.
On a truly POSIX shell that does not support "local," remove the keyword, and change the braces to parentheses to force the function into a subshell.