【发布时间】:2014-11-03 19:21:38
【问题描述】:
cmd: cat test.txt | grep 引脚
结果:打印所有包含 pin 的行
我现在只想对包含 pin 的单词进行 grep。 这样做的命令是什么?
谢谢!
大家好,谢谢你们的cmets。 我正在使用 Git Bash(版本 1.9.4)。 此 shell 中的 grep 没有 -o 选项。 有一个 -w 选项。 我试过: grep -w 'pin' test.txt 但它什么也没返回。
有人使用 Git Bash 来解决这个问题吗?
谢谢大家。
【问题讨论】:
-
您可以通过
grep -o只打印一行的匹配部分。 -
grep -o '\w*pin\w*' test.txt