如何实现,将一个文件倒数第7个逗号到第6个逗号之间的数值替换为0
文件1:
3,4,5,6,7,5,4,95,9
3,4,78,6,7,5,4,95,9
3,4,907,6,7,5,4,95,9
结果为:
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$(NF-6)=0; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$(NF-6)="0"; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$(NF-6)="0"; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$(NF-6)=0; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$3="0"; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
[root@Greendays lianshou]# awk -F, '{OFS=","}{$3=0; print}' n
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
3,4,0,6,7,5,4,95,9
阅读(493) | 评论(0) | 转发(0) |