shell习题-统计普通用户


写个shell,看看你的Linux系统中是否有自定义用户(普通用户),若是有,一共有几个?

 

参考答案:

假设所有普通用户都是uid大于1000的

#!/bin/bash
 n=`awk -F ':' '$3>1000' /etc/passwd|wc -l`
 if [ $n -gt 0 ]
 then
     echo "There are $n common users."
 else
     echo "No common users."
 fi