Hi,
This should be a simple one: I run the following commands in bash and ksh respectively but got differenant results:
# ls -l /var/log > /tmp/a
# vi /tmp/a
In bash shell, I got:
^[[00mtotal 827364
-rw-r----- 1 root root 189 Aug 9 00:00 ^[[00macpid^[[00m
-rw-r----- 1 root root 132 Aug 9 00:00 ^[[00;31macpid.1.gz^[[00m
-rw-r----- 1 root root 224 Jul 10 00:00 ^[[00macpid.2^[[00m
In ksh, I got:
total 828552
-rw-r----- 1 root root 189 Aug 9 00:00 acpid
-rw-r----- 1 root root 132 Aug 9 00:00 acpid.1.gz
-rw-r----- 1 root root 224 Jul 10 00:00 acpid.2
How can I remove those "^[[00m" got in bash?
Thank you!
Better to just not make them in the first place. ls --color=never
ls ought to be intelligent enough to tell when it's not writing to a terminal and avoid escape sequences, unless someone forced it always-on through an option or environment var.
1 Like
Issue solved! Thanks sent!!
I don't think BASH had anything to do with it incidentally, except in that it would load a different profile than ksh does. Perhaps something in that profile forced color always-on.
1 Like
Ok. I am going to check out the bash profiles. Thank you again!
it should be in .bashrc, and it should be alias ls='ls --color=auto'
, which should avoid printing out color codes to non-terminals.
1 Like
It may also be in the LS_COLORS environment variable.
# grep -i color .bash_profile
alias ls='ls --color'
Thanks!