Here is a little shell script to print out what is easily seen in /proc/*/cmdline. This requires a GNU xargs that supports NULL termination (or something compatible); as I understand it, this cannot be done with POSIX tools. $ cat shps #!/bin/dash for path in /proc/*/cmdline do p=${path#*/} p=${p#*/} p=${p%/*} case "$p" in *[!0-9]*) continue;; esac c="$(xargs -0 echo
You can do this with `tr`, right?
#!/bin/dash
for path in /proc/*/cmdline
do
p=${path#*/} p=${p#*/} p=${p%/*}
case "$p" in *[!0-9]*) continue;; esac
c="$(tr '\0' ' '
Those escape sequences are covered in the standard: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...(But please correct me if I'm missing something!)
This also avoids (POSIX-)undefined behavior with `echo` in case one of the processes' `argv[0]` happens to begin with `-n` or any argument contains a backslash.