【发布时间】:2013-10-18 16:38:12
【问题描述】:
我有一个文本文件,其中包含类似的行

The above screenshot shows how you can delete posts by tags.

The above screenshot shows how you can delete posts by custom taxonomies.
我想将这些行替换为(注意行号是从上一行的文件名中检索的)
3. The above screenshot shows how you can delete posts by tags.
4. The above screenshot shows how you can delete posts by custom taxonomies.
不应编辑其他行。
我可以写一个正则表达式来匹配这个数字,但是我不确定在替换时如何再次引用这个数字。
请让我知道如何在 awk 中进行操作。
更新:请注意,我不能使用 GNU 版本,它需要同时在 Mac 和 Ubuntu 中运行。
【问题讨论】:
-
您是否受限于使用 awk?
-
@devnull 不幸的是,是的,因为这是更大的 awk 脚本的一部分。