Since there's a 15-character limit on the length of process names in pgrep, I've been using pgrep -f to give me a list of process id's of running commands with longer names. However, it includes the full command line parameters, and this gives wrong results.
For example: suppose my_long_script_name.sh is running while I vi my_long_script_name.sh (ignore editing a running program for the moment).
If I run pgrep -f my_long_script_name.sh, it returns the process id of both my_long_script_name.sh and vi my_long_script_name.sh.
How can I get a list of process id's (that I can feed to kill in a list, the same way pgrep -d ' ' makes them) that are based only on process names not parameter lists?
I'm running Buster but see the same problem in earlier OS's such as Wheezy. As requested, if I run sed -n l "/proc/$pid/comm", where $pid is $BASHPID of my terminal session, I get bash$. If I run sed -n l "/proc/$pid/cmdline", I get -bash\000$. That's a lower case L, not a one, after -n. If I run cat -vte, it hangs.
pgrep -ldo what you mean? – Jos Nov 21 '20 at 13:19