UNIX: Strange exit if smaller

If I execute the ls command with a smaller channel, I get strange output

ESC[00mESC[00mfile1.ccESC[00m
ESC[00file2.ccESC[00m
ESC[00file3.ccESC[00m

(there is an ESC line between the characters).

Without ls output:

file1.cc    file2.cc    file3.cc

How to fix it?

+3
source share
4 answers

I assume that you have an option --color=alwaysfor ls, set either through an alias, either in a function, or in an environment variable LS_COLORS, and lssend the color directives to the nonterminal (that is, your pipe - less).

+4
source

Use less -Ror set the environment variable LESSto -R.

+3
source

, , escape- ANSI . ls --color=no.

+1

less -r.

+1
source

Source: https://habr.com/ru/post/1768756/


All Articles