我有一个大文件如下
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 ],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 ],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 ],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11],
现在,我想更新整个文件,添加逗号(,)
和数字(12)
,使其看起来如下所示
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
我无法手动完成此操作,是否有更简单的sed/awk命令来完成此操作?
我尝试了sed 's/]/, 12]/g' <path_to_the_file>
,但这比我想要的方式错误
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 , 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 , 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10 , 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12],
这不是我想要的结果。
1条答案
按热度按时间kcugc4gi1#
您可以捕获
]
之前出现的所有空格字符