Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

last - analysis

Status
Not open for further replies.

dsawk

Programmer
Oct 6, 2005
4
DE
hello,

i use last command to get logins.

i want to filter it. there are user-id`s and technical users. user-id`s starts with d, b or tt and then there are 4 or 5 digits. technical user do not have that syntax.

for example
user-id:
b99999
b11111
tt8888

technical user:
aixuser
staff

i just want to get the lines with technical user.
can i get them with a command like

last | awk ....

thanks.
 

Works on my Solaris 7 box:

Code:
last|awk ' { if ($1 ~ /^(tt|d|b)/)
          print $1  } '

If you want unique users, I'd pipe the above to the uniq command.
 
thanks for your reply

when i use

Code:
last|awk ' { if ($1 ~ /^(tt|d|b)/)
          print $1  } '

then maybee there are technical user that start also with tt, d or b. do you have an idea with the length of 6 (tt, d or b and then 4-5 digits)?
 
How about something like this:

Code:
last|nawk ' { if ($1 ~ /^(tt|d|b)/)
         {
         sguy=$1
         gsub("^(tt|d|b)", "", sguy) # get rid of the alphas
         if (sguy ~ /^[0-9][0-9][0-9][0-9]$/ || sguy ~ /^[0-9][0-9][0-9][0-9][0-9]$/)
            print $1

         }
} '

Note my switch to nawk for Solaris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top