Know how many users have connected to my computer in the last week, and how many time has been connected each one

后端 未结 2 666
独厮守ぢ
独厮守ぢ 2021-01-25 09:02

I need a script which shows a summary of which users have connected to my computer during the last week and how often.

I know I can use last and filter the

2条回答
  •  别那么骄傲
    2021-01-25 09:19

    Try this

    Steps

    1. last > login.txt

    2. last | awk '{print $3}' | sort -u > names.txt

    3. Iterate each lines from names.txt and apply grep "line1" login.txt | wc -l

    you will get count for each user (each user is each line in names.txt)

提交回复
热议问题