专栏
扫码关注公众号
利用awk命令取出/etc/passwd里面可以登录虚拟机的普通用户?
rootak8s20:40:25-1#awk-F":"'$NF~/bash$/&&$3>=1000{print$0}'/etc/passwdWish:x:1000:1000::/home/wish:/bin/bash
查找文件中1到20行之间,同时将"aaa"替换为"AAA","ddd"替换"DDD"
awk'NR==1,NR==20{gsub(/aaa/,"AAA");gsub(/ddd/),"DDD"}1'file.txtsed-n'1,20{s#aaa#AAA#g;s#ddd#DDD#g}'file.txtsed'1,20p'file.txt|tr"ad""AD"sed"1,20y/ad/AD/"file.txtsed"1,20s#[ad]#\U&#g"file.txtawk'NR==1,NR==20{printtoupper($0)}'file.txt