Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2072903
  • 博文数量: 470
  • 博客积分: 10206
  • 博客等级: 上将
  • 技术积分: 5620
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-03 12:50
文章分类

全部博文(470)

文章存档

2012年(1)

2011年(18)

2010年(47)

2009年(404)

分类:

2009-04-11 11:08:14

如何实现,将一个文件倒数第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) |
0

上一篇:AWK初学求教一个问题

下一篇:sed 匹配单词

给主人留下些什么吧!~~