Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 zcat 查看行的索引?我试图找到一个 zcat 的标志,但没有找到一个显示行号的标志。
示例:我的文件包含以下行:
Hello everybody! aaa bbb aaa Hello
我想从这个命令中得到什么:
zcat file | grep Hello
是:
1 Hello everybody! 3 aaa Hello
有任何想法吗?谢谢!
您可以在grep命令中 使用-n标志来查看行号。
$ zcat hello.zip | grep -n "Hello" 1:Hello everybody! 3:aaa Hello ubuntu14@ubuntu14:~/Public$