- 论坛徽章:
- 13
|
本帖最后由 ulovko 于 2012-05-24 20:17 编辑
- SED:
- > cat out
- 1 "a":"1", "b":"2.3", "c":"1.235"
- 2 "a":"1.1","c":"1.23d","b":"2.32"
- 3 "b":"2.33", "c":"1.233","a":"1.2"
- 4 "b":"2.3f", "a":"1.3", "c":"1.23g"
- 5 "a":"1.4", "b":"2.3y", "c":"1.23h"
- > sed 's/.[abc]...//g;s/[" ]/ /g' out
- 1 1 , 2.3 , 1.235
- 2 1.1 ,1.23d ,2.32
- 3 2.33 , 1.233 ,1.2
- 4 2.3f , 1.3 , 1.23g
- 5 1.4 , 2.3y , 1.23h
复制代码
- AWK:
- > cat out
- 1 "a":"1", "b":"2.3", "c":"1.235"
- 2 "a":"1.1","c":"1.23d","b":"2.32"
- 3 "b":"2.33", "c":"1.233","a":"1.2"
- 4 "b":"2.3f", "a":"1.3", "c":"1.23g"
- 5 "a":"1.4", "b":"2.3y", "c":"1.23h"
- > awk -F'"' '{print NR,$4","$8","$12}' out
- 1 1,2.3,1.235
- 2 1.1,1.23d,2.32
- 3 2.33,1.233,1.2
- 4 2.3f,1.3,1.23g
- 5 1.4,2.3y,1.23h
复制代码 |
|