hi
I m trying to display the processes of each user but its coming in one line like
george wilkins
PID TTY TIME CMD 7661 ? 00:00:01 sshd 7662 pts/6 00:00:00 bash
i want the output to be like
PID TTY TIME CMD
7661 ? 00:00:01 sshd
7662 pts/6 00:00:00 bash
my code is
proc=$(users)
for i in $proc
do
echo $(cat /etc/passwd | grep "$i" | cut -d ':' -f 5)
echo $(ps -u $i)
done
for i in `users`
do
cat /etc/passwd | grep \^"$i:" | cut -d ':' -f 5
ps -u $i
done
i.e. Put the output to standard output rather than into a shell variable.
The modified grep gives an exact match on username in the first field in passwd (e.g fred and freddy won't gove false matches).
sorry its still not working..My Question is to diplay the processes in line for each user
but its displaying in one line
PID TTY TIME CMD 10886 ? 00:00:00 sshd 10887 pts/3 00:00:00 bash
like this