Почему бы не использовать pgrep:
pgrep "^vi" | wc -l
pgrep man page:
СИНТАКСИС pgrep [options] pattern
ОПИСАНИЕ pgrep looks through the currently running processes and lists the process
IDs which matches the selection criteria to stdout.
EDIT: (Использование файл):
ps aux > file1
awk '{ print $11 }' file1 | egrep '^vi' | wc -l