How to grab last column - Korn Shell

I need to grab the last column of data from each line of output from

ps -ef | grep sshd

Example:

    root 47645194  1703952   0   Oct 23      -  0:01 sshd: jcagle [priv]
 rnewmon 48694012 27984606   0 08:36:02      -  0:00 sshd: rnewmon@pts/292

Because some of these process have been out there longer than one day there is an extra column so my simple knowledge of awk only works on the ones without the month/day. I understand that I could modify the awk statement to look for column 10 but would rather not have to test if the file line has 10 columns or 9.

awk '{print $9"}

Thanks for any advice you can provide me.
Justin

awk '{ print $NF }'

Alternatively, you can use pgrep to feed pids to ps and tell ps to only print the information that interests you.

Regards,
Alister

for sshd data in example listed try:

ps -ef | grep sshd: | grep -v -E " grep | sed " | sed 's/.*sshd: *//'
 
ps -ef | awk -F"sshd:" '/sshd:/ && !/awk/ { print $NF } '

Thank you all for your reply. I apologize for the delay in getting that conveyed to you. Once I leave work I try to leave work and just had some other things going this morning and had not started back to work on my script. I have not tried Alister's suggestion yet (I'm sure it works), got to figure out how to get ps to do that but the other suggestions got me what I needed or something to work with. Thanks again.

If pgrep is not available (HP-UX?), you could format the output from ps with the -o option.