[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash, grep, and regular expressions



Michael Marsh wrote:
On Sat, 19 Feb 2005 07:45:57 -0800, Freddy Freeloader
<fredddy@cableone.net> wrote:

I set it up as alias ls="ls -al --color=always".  On one of the IT sites
I spend a fair amount of time on a *nix admin with quite a few years
experience said he has run into problems using aliases on some machines
too, so I guess it isn't unknown.  I thought it was pretty strange that
it screwed things up too, but it certainly did make a difference.


Perhaps the problem is that this produces lines like:
-rw-r--r--   1 marsh marsh      6811 Sep 27 22:50 ESC[0m.XdefaultsESC[0m
That is, it's including ASCII color codes.

This was produced with:
ls -al color=always | cat

From ls(1):
       By default, color is not used to distinguish types of files.   That  is
       equivalent to using --color=none.  Using the --color option without the
       optional WHEN argument is equivalent  to  using  --color=always.   With
       --color=auto,  color  codes  are output only if standard output is con-
       nected to a terminal (tty).

If you change your alias to "ls -al --color=auto", you should be
golden, since ls will recognize that it's writing to a pipe, not the
terminal.


Oh, how I love people with real skills. That's the ticket. This was really a good learning experience. I learned far more about my system than I did about regular expressions, and I still learned quite a bit about them too.

Thanks a lot.



Reply to: