About how to exclude the ps command itself from the output when running the โpsโ command on the Bash language command line of Linux computers and servers.
When you run the ps command, the ps command itself and the commands piping it also end up in the output.
For example, if you want to check if node.js might be running in the background in the current shell.
tty="$( tty | ag -o '\d+' )" ; ps aux | ag "(tty|pts)/${tty}" | awk '!/\s(Ss)\s/'
This produces output like the following:

yuis 17361 0.0 0.0 1175236 26304 pts/8 Sl 00:49 0:01 node tmp.js
yuis 18990 0.0 0.0 873500 26608 pts/8 Sl 01:21 0:00 node tmp.js
yuis 20377 0.0 0.0 874012 26656 pts/8 Sl 01:48 0:00 node tmp.js
yuis 24704 0.0 0.0 16676 1868 pts/8 R 02:44 0:00 ps aux
yuis 24705 0.0 0.0 11416 1080 pts/8 R 02:44 0:00 ag (tty|pts)/8
yuis 24706 0.0 0.0 25676 1824 pts/8 R 02:44 0:00 bash -l -i
Of this output, the important part is only the following:
yuis 17361 0.0 0.0 1175236 26304 pts/8 Sl 00:49 0:01 node tmp.js
yuis 18990 0.0 0.0 873500 26608 pts/8 Sl 01:21 0:00 node tmp.js
yuis 20377 0.0 0.0 874012 26656 pts/8 Sl 01:48 0:00 node tmp.js
If you want output like this, do the following:
Since the output of ps aux is sorted by command start time, you can delete the line containing ps aux and subsequent lines with sed โ/ps aux/,+1 dโ.
tty="$( tty | ag -o '\d+' )" ; ps aux | ag "(tty|pts)/${tty}" | awk '!/\s(Ss)\s/' | sed '/ps aux/,+1 d'
