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/
相关文章:
python - Django createsuperuser 抛出 django.core.exc
ruby-on-rails - 捆绑安装不适用于 bundler 2.0.1 的 rails-4.2
hibernate - 当我从 POST 方法更新它时,@CreationTimestamp 列设置
java - 修复 Java newInstance() 已弃用
python - MacOS 构建问题 lstdc++ not found while buildi
python - 如何更改 Rstudio 中的默认 python 版本/路径