cancel
Showing results for 
Search instead for 
Did you mean: 

last command output

 
SOLVED
Go to solution
John Ferro
Regular Advisor

last command output

Hello,

1)I have HP-UX 11i v2, i would like to subtitute from output of "last" command to get only user name and date (day & time) how this possible?
2) As I have to check which user logged in and when exactly?
3) And which user is created but not logged in since long time back?

Regards,
Faisal M.

5 REPLIES
Pete Randall
Outstanding Contributor
Solution

Re: last command output

Try using awk:

last | awk '{ print $1 " " $3 " " $4 " " $5 " " $6 }'

That should take care of question 1. For 2, you could use grep to selectively print the user.

For 3, you could try finger:

for i in `cat /etc/passwd | awk -F : '{ print $1 }
do
finger $i |grep Never


Pete

Pete
John Ferro
Regular Advisor

Re: last command output

Mr. Pete,

Thanks for your kind response, for Q3, finger doesn't get any output just only '>'

what could be the reason...
James R. Ferguson
Acclaimed Contributor

Re: last command output

Hi:

> Mr. Pete, Thanks for your kind response, for Q3, finger doesn't get any output just only '>'

This is the shell telling you that it expects additional input before it processes your command.

Pete simply forgot a 'done' to complete the 'do' loop.

You could also eliminate the extra 'cat' process by doing:

for USER in $(awk -F: '{print $1}' /etc/passwd)
do
finger ${USER}
done

Regards!

...JRF...
John Ferro
Regular Advisor

Re: last command output

Dear James,

Thanks for your kind response,

what about for never logged in do i have to add upon what you said, |grep Never?
James R. Ferguson
Acclaimed Contributor

Re: last command output

Hi (again):

> what about for never logged in do i have to add upon what you said, |grep Never?

Yes, I missed that Pete had covered that nicely :-(

Regards!

...JRF...