当前位置: 技术问答>linux和unix
关于shell中数据替换的问题
来源: 互联网 发布时间:2017-02-28
本文导语: 2012060100024166311|00000000000000000000|000|00000000|0|00000000000|1338537227|JC0001| |28010000|28120000|0|客家饭店| |0 | |0 |30 |0 |0 |f90c19896a4986faae8c0727537f3f33| |000 |282803406951;282803204738;282801403625| |^A 2012060100024162345|00000...
2012060100024166311|00000000000000000000|000|00000000|0|00000000000|1338537227|JC0001| |28010000|28120000|0|客家饭店| |0 | |0 |30 |0 |0 |f90c19896a4986faae8c0727537f3f33| |000 |282803406951;282803204738;282801403625| |^A
2012060100024162345|00000000000000000000|000|00000000|0|00000000000|1338537227|JB0001| |28020000|28120000|0|客家饭店| |0 | |0 |30 |0 |0 |f90c19896a4986faae8c0727537f3f33| |000 |282803406951;282803204738;282801403625| |^A
数据格式是这样的,现在的需求如下:
1.以“|”把数据分开
2.取出第十和第十一列,即:28010000和28120000对应的列
3.把取出的数据的后六位全部换成0,前两位保持不变。
新人,求指导!新人没什么分
2012060100024162345|00000000000000000000|000|00000000|0|00000000000|1338537227|JB0001| |28020000|28120000|0|客家饭店| |0 | |0 |30 |0 |0 |f90c19896a4986faae8c0727537f3f33| |000 |282803406951;282803204738;282801403625| |^A
数据格式是这样的,现在的需求如下:
1.以“|”把数据分开
2.取出第十和第十一列,即:28010000和28120000对应的列
3.把取出的数据的后六位全部换成0,前两位保持不变。
新人,求指导!新人没什么分
|
[User:root Time:00:17:26 Path:/home/liangdong/shell]$ ./test.sh
28000000,28000000
[User:root Time:00:17:26 Path:/home/liangdong/shell]$ cat test.sh
#!/bin/bash
echo "2012060100024166311|00000000000000000000|000|00000000|0|00000000000|1338537227|JC0001| |28010000|28120000|0|客家饭店| |0 | |0 |30 |0 |0 |f90c19896a4986faae8c0727537f3f33| |000 |282803406951;282803204738;282801403625| |" | awk -F '|' '{print substr($10, 1, 2)"000000,"substr($11, 1, 2)"000000";}'