If you are willing to allow some changes in the formatting, you may as well just pipe it through cat
ls | cat
No colours, but newline for each entry.
Edit:
Turning off colors via the shell settings
Check your shell's rc file(s) and see where colors are set, then make a new .<shell>rc_mono
where these settings are removed, source it and done. E.g. for bash:
$cat ~/.bashrc_mono
export TERM=xterm-mono
. ~/.bashrc
alias ls='ls --color=none'
alias grep='grep --color=none'
Note that . ~/.bashrc
must precede the new aliases for ls
and grep
as their coloring usually is set in ~/.bashrc
.
So all you need to do is
. ~/bashrc_mono ; ls
Accordingly a "redo colors"-rc might be nice:
$cat ~/.bashrc_recolorize
export TERM=xterm-256color
. ~/.bashrc
Use e.g. htop
and you will see the difference.
man ls
. GNUls
has the--color=never
option, and there's theLS_COLORS
variable. – waltinator Jun 15 '21 at 12:25alias ls='ls --color=never'
– Panki Jun 15 '21 at 13:13ls
output is typically only colored in a terminal becausels
is aliased to something likels --color=auto
. So to get uncolored output it is sufficient to prevent alias expansion ex.\ls
. See also How to turn off color withls
? – steeldriver Jun 15 '21 at 15:27ls
. I want a general solution that will turn off colors for a command – KMA Badshah Jun 15 '21 at 16:58