ls
命令按行输出结果:
AndroidSandbox/ kotlin-native-intellij/
arc-theme-macos/ kotlin-native-sandbox/
BobkoLauncher/ kotlin-ref-delegation/
...
如何获取此输出的前 n
行? ls | head -n 2
不起作用,因为它需要前两个文件,但我需要前两行输出。
最佳答案
简答:
无缓冲的 ls |头-n 2
解释:
https://unix.stackexchange.com/questions/249723/how-to-trick-a-command-into-thinking-its-output-is-going-to-a-terminal
关于bash - 如何获取 `ls` 命令的前 n 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55463646/