sed -e "12s/^./1/" staffpms | awk '-F\' '{if (NR == 6) { {split($1, sarr, ","); nattrs = int(sarr[1])}
{idx =2; vidx=(nattrs * 2) + 2; replaced = 0}
while((!replaced) && (idx < ((nattrs*2)+2))){ print $idx, "@@@@@@@@@@@@@@@@@@@@@@@@";
if($idx == "NAME"){ print "================================";
$vidx = "@@@@@"; replaced = 1;
OFS="\\\\"; print $0
}
idx += 2; vidx += 1
}
{if (!replaced) print $0}
}else print $0}
'
This issue caused by the difference between /bin/awk and /usr/xpg4/bin/awk.
If parameter $0 doesn't change after the OFS command called in xpg4 awk ,the OFS won't work as we expect.
再来一段非常风骚的脚本,你能猜出它是干什么的吗?
awk '{if(!($0 in B))print;B[$0]=1}'
替换字符
$tr -s "[:]" "[/]" < test