Issue
I am trying to display full username by PID number
The first Approach i tried :
PID=12345
PID_USER=`ps -u -p ${PID}| awk '{print $1}' | tail -1`
echo $PID_USER
this will display as systemU+, i want to display as SystemUser_Farid
i have tried a second approach using ps axo , script used as
ps axo user:20,pid
, however , this is printing the whole list of processes , using ps axo -p ${PID} user:20,pid
doesnt show any result.
Solution
Use -o format
for a user-defined format and only print the user name:
ps -o user= -p "$PID"
The =
disables printing the header line.
Answered By - knittl Answer Checked By - David Goodson (WPSolving Volunteer)