The username is in column one and PID in column two of ps gaux, so I have:
ps gaux | awk '{print $2;}' | while read line ; do grep -i umask /proc/$line/status ; done
but is there a way to print the username as well?
>Solution :
I hope this helps
ps gaux | awk '{printf $1 " " ; system("grep Umask /proc/"$2"/status | tr -dc [:digit:]"); printf "\n"}'
Explanation:
- get output from ps
- print first column (username) and space
- run the grep and remove everything except the actual umask, which is a number (awk does not print the command output, it gets just printed directly from the subshells stdout)
- print a new line