加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 如何制作ls |不那么多彩?

发布时间:2020-12-15 21:09:54 所属栏目:安全 来源:网络整理
导读:使用ls或许多其他命令,我们可以得到这样的彩色结果: 但是如果这些结果太长并且在我们将这些结果管理到更少之后,颜色就会消失. 这是ls -l |的结果减: 为什么颜色会消失. 如何制作ls |的结果不那么多彩? 解决方法 从 man page for ls : Using the --color
使用ls或许多其他命令,我们可以得到这样的彩色结果:

但是如果这些结果太长并且在我们将这些结果管理到更少之后,颜色就会消失.

这是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).

请注意,始终是默认值.

从man page for less开始:

-r or --raw-control-chars

Causes “raw” control characters to be displayed.

总的来说,你需要这个:

ls -l --color | less -r

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读