shell习题-15
题目要求 写个shell,看看你的Linux系统中是否有自定义用户(普通用户),若是有,一共有几个? 核心要点 centos6 uid>=500 eentos7 uid>=1000 awk -F ':' '$3>=500' /etc/passwd|wc -l centos 5 6 awk -F ':' '$3>=1000' /etc/passwd|wc -l centos 7 awk -F 'release' '{print $2}' /etc/redhat-release|cut -d '.' -f1 参考答案 #!/bin/bash v=`awk -F 'release ' '{print $2}' /etc/redhat-release |cut -d '.' -f1` user() { if [ $1 -eq 0 ] then echo "系统没有自定义的用户" else echo "系统存在自定义用户,有$1个" fi } case $v in 5|6) n=`awk -F ':' '$3>=500' /etc/passwd|wc -l` user $n ;; 7) n=`awk -F ':' '$3>=1000' /etc/passwd|wc -l` user $n ;; *) echo "脚本出错." ;; esac 题目要求 写一个shell脚本