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
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
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?
Since I'm using bash, I used the following to achieve the desired output:
System:~ user# ls -C -w "$(tput cols)" | cat
Since I'm using bash, I used the following to achieve the desired output:
System:~ user# ls -C -w "$(tput cols)" | cat