Find the answer to your Linux question:
Results 1 to 7 of 7
Hello, I am looking for a script to take output from the last command and printing out how many times each user has logged in. I am trying to use ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    65

    Counting number of loggins from last command


    Hello,
    I am looking for a script to take output from the last command and printing out how many times each user has logged in. I am trying to use a awk script with a counter, but cant seem to get it right.
    Any help would be appreciated.
    Thanks
    Art

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Code:
    last | sort | cut -f1 -d' ' | grep -v ^$| uniq -c

  3. #3
    Just Joined!
    Join Date
    Mar 2005
    Posts
    65
    This looks good, but gives me illigal variable name error...I will play with it

  4. #4
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Try putting a space between the $ and the |

  5. #5
    Just Joined!
    Join Date
    Mar 2005
    Posts
    65
    Tried that and it says:
    cut: option requires an argument -- d
    usage: cut -b list [-n] [filename ...]
    cut -c list [filename ...]
    cut -f list [-d delim] [-s] [filename]

    I have never used cut so I am not sure were the problem is at the moment...

  6. #6
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Make sure that there is a space between the ' and the '.
    Just copy paste exactly what I typed:
    Code:
    last | sort | cut -f1 -d' ' | grep -v ^$ | uniq -c

  7. #7
    Just Joined!
    Join Date
    Mar 2005
    Posts
    65
    Thanks I figured it out...I forgotr I took out the single quotes...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •