- if ``` [sunqi@manjaro-xfce ~]$ awk -F: '{ if($3>=500 && $3<=60000) {print $1,$3}}' /etc/passwd systemd-coredump 981 systemd-network 980 systemd-oom 979 systemd-journal-remote 978 systemd-resolve 977 systemd-timesync 976 tss 975 dhcpcd 974 dnsmasq 973 avahi 971 colord 970 flatpak 969 geoclue 968 git 967 lightdm 966 nm-openconnect 965 nm-openvpn 964 openvpn 963 sunqi 1000 vncuser 1001 [sunqi@manjaro-xfce ~]$ ``` - if else ``` [sunqi@manjaro-xfce ~]$ awk -F: '{ if($3==0) {print $1" is admin"} else {print $1" not admin"} }' /etc/passwd root is admin nobody not admin dbus not admin bin not admin daemon not admin mail not admin ftp not admin http not admin ``` - if else begin 结合shell 命令 ``` [sunqi@manjaro-xfce ~]$ awk 'BEGIN{ if($(id -u) -ge 500 && $(id -u) -ne 65534) {print "是普通用户"} else {print "不是普通用户"}}' 是普通用户 [sunqi@manjaro-xfce ~]$ ``` - if else if else