如题,显示uid大于500的脚本如下:
#!/bin/bash username="$(awk 'BEGIN {FS=":"} $3 >= 500 && $3 != 65534 {print $1}' /etc/passwd)" for user in $username do id $user finger $use printf '\v' done 或: awk -F: 'BEGIN{printf "%-20s%s\n", "Username","UID"} $3>=500 && $3!=65534{printf "%-20s%s\n", $1,$3}' /etc/passwd
显示gid大于500的脚本如下:
#!/bin/bash gidlist="$(awk 'BEGIN {FS=":"} $3 >= 500 && $3 !=65534 {print $3}' /etc/group)" for gid in $gidlist do group="$(awk 'BEGIN {FS=":"} $3 == "'$gid'" {print $1}' /etc/group)" echo -e "Group=$group $(printf '%13s\t') GID=$gid" done