第一行特殊处理
原始数据
a1,2018-11-24 00:00:00,20
a2,2017-02-03 00:00:00,15
a3,2017-02-03 00:00:00,15
写法1
awk -F ',' 'NR==1{print "line1," $1 "," $3}NR>1{print $1 "," $3}' file
写法2
awk -F ',' '{if(NR==1){print "line1," $1 "," $3}if(NR>1){print $1 "," $3}}' file
输出结果
line1,a1,20
a2,15
a3,15