2006-08-30

'/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:

3 Comments:

At Saturday, April 21, 2007 at 9:54:00 PM GMT+4 , Blogger Unknown said...

ls --color=auto allows color for interactive console and normal mode when it autodetects a pipe. - Boris

 
At Wednesday, April 25, 2007 at 12:51:00 PM GMT+4 , Blogger Dimon said...

Thanks for the tip :-) The GNU ls man page is not very clear about this, but the coreutils info page explains it better.

 
At Wednesday, February 4, 2015 at 9:58:00 PM GMT+3 , Blogger Unknown said...

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