awk -F ':' '{print $1}' passwd 以冒号为分隔符,打印passwd文件的第一段
awk -F ':' '{print $1}' 1.txt
awk -F ':' '{print $1}' inittab
awk -F ':' '{print $1}' passwd
awk '{print $0}' passwd
awk '{print $1,$2}' passwd
awk -F ':' '{print $1,$2}' passwd
awk -F ':' '{print $1,$4}' passwd
awk -F ':' '{print $1"hahha"$4}' passwd
awk -F ':' '{print $1"*"$4}' passwd
awk '/oo/' passwd
awk -F ':' '$1~/oo/' passwd ~
awk -F ':' '$1 ~ /oo/' passwd ~
awk -F ':' '$1 ~ /oo/' passwd
awk -F ':' '$2 ~ /oo/' passwd
awk -F ':' '$6 ~ /oo/' passwd
awk -F ':' '/root/ {print $1,$2} /user/'
awk -F ':' '/root/ {print $1,$2} /user/ {print $1,$3}' passwd
awk '{print $0}' passwd
awk -F ':' '/root/ {print $1,$2} /run/ {print $1,$3}' passwd
awk -F ':' '/root/ {print $1,$2} /run/ {print $0}' passwd
awk -F ':' '$3==0 {print $1}'pa
awk -F ':' '$3==0 {print $1}' passwd
awk -F ':' '$3>=500 {print $1}' passwd
awk -F ':' '$3>="500" {print $1}' passwd
awk -F ':' '$3>=500 {print $1}' passwd
awk -F ':' '$7!="/sbin/nologin" {print $1}' passwd
awk -F ':' '$7!="/sbin/nologin" ' passwd
awk -F ':' '$7!="/sbin/nologin" {print $0} ' passwd
awk -F ':' '$7!="/usr/sbin/nologin" {print $0} ' passwd
注意事项:数字比对的时候 不要加 “双引号”“”
分段中的$0 表示 全部的内容
不指定分隔符,默认为空格 或者空白字符
awk -F ':' '$3<$4' passwd
awk -F ':' '$3==$4' passwd
awk -F ':' '$3>"5"&&$3<"7"' passwd
awk# awk -F ':' '{OFS="#+#"} $3>1000||$7 ~ /bash/ {print $1,$3,$7}' tt.txt
awk -F ':' '{OFS="#+#"} {print $1,$3}' tt.txt
awk -F ':' '{OFS="#+#"} $3>1000||$7 ~ /bash/ {print $1,$3}' tt.txt
awk -F ':' '{OFS="#+#"} $3>1000||$7 ~ /bash/ {print $1,$3,$7}' tt.txt
awk -F ':' '{OFS="#+#"} $3>1000||$7 ~ /bash/ {print $0}' tt.txt
awk -F ':' '{OFS="#+#"} {print $1,$3,$7}' tt.txt
awk -F ':' '{OFS="#+#"}{if ($3>1000) {print $1,$3,$7}}' tt.txt
awk -F ':' '{OFS="#+#"} $3>1000 {print $1,$3,$7}' tt.txt
awk -F ':' '{(tot=tot+$3)}; END {print tot}' tt.txt tot求和
分段 tot=tot+$3 tot值每次循环加第三段值 第一次 为0 不存在 默认tot不存在为0 ;第二次为 第一行的第三段+第二行的第三段
第三段所有的和 ,相当于求一列值
不断尝试,不断练习