1:cp /etc/passwd /root/test.txt sed -n '1,$'p /root/test.txt 2:sed -n '3,10'p test.txt 3:sed -n '/root/'p test.txt 4:sed '15,$'d test.txt 5:sed '/bash/'d test.txt 6:sed 's/root/toor/g' test.txt 7:sed 's/\/sbin\/nologin/\/bin\/login/g' 8:sed '5,10s/[0-9]//g' 9:sed 's/[^0-9a-zA-Z]//g' 10:sed -r 's/([^:])(.*:)([^:])/\3\2\1/g' 11.sed 's#\([^0-9][^0-9]*\)\([0-9][0-9]*\)\([^0-9].*\)\([^a-zA-Z]\) \([a-zA-Z][a-zA-Z]*$\)#\1\5\3\4\2#' test.txt 看暈了 12. sed 's#\([^0-9][^0-9]*\)\([0-9][0-9]*\)\([^0-9].*$\)#\1\3\2#' test.txt看暈了。。 13: sed -r '20,$s/(.*)/aaa:\1/g'
1: awk '{print $0}' test.txt 2: awk '/bash/ {print $0}' test.txt 3: awk -F ':' '$3==0 {print $0}' test.txt 4: awk -F ':' '$1=="root"'|sed 's/root/toor/g' 5: awk -F ':' '{print $NF}' test.txt 6: awk -F ':' '$NR>20' test.txt 7: awk -F ':' '$3<$4 ' test.txt 8: awk -F ':' '{print $1"@"$NF}' test.txt 9: awk -F ':' '{sum=sum+$4};END{print sum}' test.txt