为什么当管道LS给不同的输出 [英] Why does ls give different output when piped
本文介绍了为什么当管道LS给不同的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
打印到终端直接:
$ ls
a.out avg.c avg.h
管道到猫
$ ls | cat
a.out
avg.c
avg.h
为什么 LS
给出了基于目的地不同的输出?
Why does ls
give a different output based on destination?
推荐答案
LS
实际上可以判断它是否输出到终端或文件(使用 isatty
库调用)。如果它检测到一个控制台,它会尽量做到以方便查看更紧凑。
ls
can actually determine if it's outputting to a terminal or a file (with the isatty
library call). If it detects a console, it will try to make it more compact for easier viewing.
这篇关于为什么当管道LS给不同的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文