我如何使用awk:
Foo Figure
![Figure. Foo](images/foo.png)
Bar Figure
![Figure. "Bar"](images/bar.png)
Foo Figure
![Figure 1. Foo](images/foo.png)
Bar Figure
![Figure 2. "Bar"](images/bar.png)
答案 0 :(得分:4)
$ awk 'sub(/!\[Figure/,"& "i+1){i++} 1' file
Foo Figure
![Figure 1. Foo](images/foo.png)
Bar Figure
![Figure 2. "Bar"](images/bar.png)
答案 1 :(得分:1)
awk '/Figure\./{gsub(/Figure/, "Figure " ++i)}1' File
输出:
Foo
![Figure 1. Foo](images/foo.png)
Bar
![Figure 2. "Bar"](images/bar.png)