I'm running a process and I'm counting the number of threads withps huH p <PID_OF_U_PROCESS> | wc -lI can run this thread with watch like this;watch -n 1 ps huH p <PID_OF_U_PROCESS> | wc -lThis will output the number of threads the process is running, but usually that number doesn't change.How can I only print the new number to screen if it changed from the last time the command was run?For example:646564(a few minutes go by)65Etc.
Watch: Only print to screen if output has changed since last output
output;watch
You could just pipe to uniq:while ps -o nlwp= -p $pid; do sleep 1; done | uniq