Eg. Processes being run by various users are as below.
root 5 xuser 3 yuser 1
Then the script should give the output as:
root ..... xuser ... yuser .
Using Perl, and assuming that the data is located in
$ perl -ne '/^(\w+)\s+(\d+)$/ && printf("%s\t%s\n", $1, "." x $2)' file root ..... xuser ... yuser .
You may also apply this on a data stream:
somecommand | perl -ne '...as above...'
The Perl script matches the initial string and the number in the input, and the outputs the string and the appropriate number of dots, with a tab character in-between.
With a bit of tweaking of the above (to be able to read
uniq -c output, which has the number first), the following would get the number of processes running for each user and display the counts as dots:
$ ps -ax -o user= | sort | uniq -c | perl -ne '/^\s*(\d+)\s+(\w+)$/ && printf("%-10s%s\n", $2, "." x $1)' _dbus . _dhcp . _ntp .. _pflogd . _slaacd .. _smtpd ..... _smtpq . _syslogd . _unbound . kk ................ root ..........................
ps command might need modification to output the correct thing on Linux (I'm using OpenBSD here, but it seems to do the right thing on Ubuntu too). The Perl script has changed from the first variation so that it properly reads
uniq -c output and it formats the lines to allow for usernames of length 10 or less.