7.Sed 特殊操作符

=

显示当前的行号

[jerry]$ sed '=' books.txt 

On executing the above code, you get the following result:

1 
1) A Storm of Swords, George R. R. Martin, 1216 
2 
2) The Two Towers, J. R. R. Tolkien, 352 
3 
3) The Alchemist, Paulo Coelho, 197 
4 
4) The Fellowship of the Ring, J. R. R. Tolkien, 432 
5 
5) The Pilgrimage, Paulo Coelho, 288 
6 
6) A Game of Thrones, George R. R. Martin, 864

&

匹配的内容

[jerry]$ sed 's/[[:digit:]]/Book number &/' books.txt

On executing the above code, you get the following result:

Book number 1) A Storm of Swords, George R. R. Martin, 1216 
Book number 2) The Two Towers, J. R. R. Tolkien, 352 
Book number 3) The Alchemist, Paulo Coelho, 197 
Book number 4) The Fellowship of the Ring, J. R. R. Tolkien, 432 
Book number 5) The Pilgrimage, Paulo Coelho, 288 
Book number 6) A Game of Thrones, George R. R. Martin, 864 

\1 …\n


模式匹配的子匹配

猜你喜欢

转载自blog.csdn.net/successdd/article/details/79078067