【发布时间】:2015-10-17 18:21:20
【问题描述】:
我有一个这种形式的文件:
2ThroughputRule.js:128 bw 3545891 3545891 3545891
ThroughputRule.js:128 bw 124776 1835334 1151111
ThroughputRule.js:128 bw 1959606 1876758 2435492
ThroughputRule.js:128 bw 3213333 1765905 2979981
2ThroughputRule.js:128 bw 1985927 2386289 2284143
我想要一种处理文件的方法,以便 shell 脚本可以读取每行的第一个字符,如果它找到一个数字,则将该行从数字旁边复制该行的次数,直到下面的 EOL。
比如我有
2ThroughputRule.js:128 bw 3545891 3545891 3545891
结果是
2ThroughputRule.js:128 bw 3545891 3545891 3545891
ThroughputRule.js:128 bw 3545891 3545891 3545891
如果我有
4ThroughputRule.js:128 bw 3545891 3545891 3545891
ThroughputRule.js:128 bw 3545891 3545891 3545891
ThroughputRule.js:128 bw 3545891 3545891 3545891
ThroughputRule.js:128 bw 3545891 3545891 3545891
有可能吗?
【问题讨论】:
-
我编辑了我的问题,谢谢
标签: linux bash file shell text