[Solved] in Bash,How to check user login [closed]


This will count multiple logins of a single user as multiple matches i.e if you ssh into a machine 3 times with the same account this will show 3 users

echo $(date) $(who | awk '{print $1}' | wc -l) users >> log.txt

To treat multiple logins from one username as one match this is what you want:

echo $(date) $(who | awk '{print $1}' | uniq | wc -l) users >> log.txt

solved in Bash,How to check user login [closed]