1. #!/bin/bash
    2. declare -i count=0
    3. while true;do
    4. if who |grep -q -E "^root"
    5. then
    6. echo -e "用户root 登陆了系统\n 这是第$count 次"
    7. break
    8. else
    9. let count++
    10. fi
    11. sleep 3
    12. done