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.
我有一个包含以下文本的文件:
text START This has to be printed STOP more text
现在我希望打印 START 和 STOP 之间的文本。我写了以下内容:
cat file | sed '/START/,/STOP/p'
但这似乎并没有做我想要的。有什么建议么?
如果要在开始和停止标志之间打印,请尝试:
sed -n '/START/,/STOP/ { //!p }' file.txt
结果:
This has to be printed
cat file | sed -n '/START/,/STOP/p'
需要 -n 来抑制 sed 的默认打印。