如何使用sed查找单词linux的行?后来用linux这个词显示第一行10?EX:
cat file | sed -e '/linux/!d' -e '10!d' ### I can not display the first 10 lines of the word linux
cat file | sed '/linux/!d' | sed '10!d' ### It is well
Run Code Online (Sandbox Code Playgroud)
如何让它与一个sed一起工作?
cat file | sed -e '/linux/!d; ...?; 10!d'
Run Code Online (Sandbox Code Playgroud)
...? - 存储缓冲区linux?10后来切线?
有人向我解释?
我会用awk:
awk '/linux/ && c<10 {print;c++} c==10 {exit}' file
Run Code Online (Sandbox Code Playgroud)