top -c command in linux to filter processes listed based on processname

Using pgrep to get pid’s of matching command lines:

top -c -p $(pgrep -d',' -f string_to_match_in_cmd_line)

top -p expects a comma separated list of pids so we use -d',' in pgrep. The -f flag in pgrep makes it match the command line instead of program name.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)