这只是我无法解决的好奇心(尝试sed,awk,tail,head等).
这有效:
$ ls --help | head -n 2
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Run Code Online (Sandbox Code Playgroud)
为什么使用其他命令它不起作用?
$ tree --help | head -n 2
Prints the whole --help! not just the first 2 lines!
Run Code Online (Sandbox Code Playgroud)
tree(以及其他一些命令)将他们的帮助打印到stderr,而不是stdout.您可以通过使用|&而不是重定向两者|:
tree --help |& head -n2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |