GNU'ls'命令不在管道上输出相同的命令 [英] GNU 'ls' command not outputing the same over a pipe
本文介绍了GNU'ls'命令不在管道上输出相同的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在系统上执行命令ls
时,得到以下输出:
When I execute the command ls
on my system, I get the following output:
System:~ user# ls
asd goodfile testfile this is a test file
但是,当我将ls
用管道传输到另一个程序(例如cat
或gawk
)时,将输出以下内容:
However, when I pipe ls
to another program (such as cat
or gawk
), the following is output:
System:~ user# ls | cat
asd
goodfile
testfile
this is a test file
如何获取ls
来读取终端尺寸并通过管道将其输出,就像直接打印到终端上一样?
How do I get ls
to read the terminal size and output the same over a pipe as it does when printing directly to the terminal?
由于我使用的是bash,因此使用以下命令来实现所需的输出:
Since I'm using bash, I used the following to achieve the desired output:
System:~ user# ls -C -w "$(tput cols)" | cat
推荐答案
由于我使用的是bash,因此我使用以下方法来实现所需的输出:
Since I'm using bash, I used the following to achieve the desired output:
System:~ user# ls -C -w "$(tput cols)" | cat
这篇关于GNU'ls'命令不在管道上输出相同的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文