'/usr/linux/bin/ls --color' on AIX
I have a habit of using GNU coreutils on non-GNU systems (e.g. AIX) for my shell environment, so I install the coreutils package from the AIX Toolbox for Linux on all my machines. My 'ls' is aliased to '/usr/linux/bin/ls --color' to have ANSI colored output. Unfortunately, this has unwanted side effects when piping 'ls' output to other commands, apparently because of some color-related control characters. Consider:
# alias ls
alias ls='/usr/linux/bin/ls --color'
# ls ./foobar
./foobar
# ls ./foobar | xargs /usr/bin/rm -e
rm: ./foobar: A file or directory in the path name does not exist.
However, using the standard AIX 'ls' works:
# /usr/bin/ls ./foobar | xargs /usr/bin/rm -e
rm: Removing ./foobar
Had to break my head a little before guessing this one.
Labels: aix
3 Comments:
ls --color=auto allows color for interactive console and normal mode when it autodetects a pipe. - Boris
Thanks for the tip :-) The GNU ls man page is not very clear about this, but the coreutils info page explains it better.
colorized ls that works if you can't install gnu ls: https://gist.github.com/earonesty/e04e94bbb139f6d645c6
Post a Comment
Subscribe to Post Comments [Atom]
<< Home