使用 ls
或许多其他命令,我们可以获得像这样的彩色结果:
但如果这些结果太长,并且在我们将这些结果通过管道传输到 less
之后,颜色就会消失。
这是 ls -l | 的结果少
:
- 为什么颜色消失了。
- 如何生成
ls | 的结果少
多彩?
最佳答案
来自man page for ls
:
Using the
--color
option without the optional WHEN argument is equivalent to using--color=always
.With
--color=auto
, color codes are output only if standard output is connected to a terminal (tty).
请注意,always
是默认值。
-r or --raw-control-chars
Causes "raw" control characters to be displayed.
总的来说,你需要这个:
ls -l --color | less -r
关于bash - 如何制作 ls |不那么丰富多彩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20929219/