FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 04-07-2008, 11:03 PM
Chris Bannister
 
Default grep trick

Hi,

If you work on the command line, here is a handy grep trick.

In your .bashrc put:

export GREP_COLOR=33
alias grep='grep --colour=always'

You can always try different values of GREP_COLOR.
Although I can't seem to get yellow.

Remember to:

source .bashrc

before trying it.

--
Chris.
======


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-07-2008, 11:31 PM
mike
 
Default grep trick

Chris Bannister wrote:

Hi,

If you work on the command line, here is a handy grep trick.

In your .bashrc put:

export GREP_COLOR=33
alias grep='grep --colour=always'

You can always try different values of GREP_COLOR.
Although I can't seem to get yellow.

Remember to:

source .bashrc

before trying it.



THAT IS WAY COOL!!!!!!
thanks for sharing


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-07-2008, 11:32 PM
Mike Bird
 
Default grep trick

On Mon April 7 2008 16:03:28 Chris Bannister wrote:
> export GREP_COLOR=33
> alias grep='grep --colour=always'

This will break any scripts which assume that the output
of grep has not been annotated with color escape sequences.

--Mike Bird


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-07-2008, 11:49 PM
Kevin Monceaux
 
Default grep trick

Chris,

On Tue, 8 Apr 2008, Chris Bannister wrote:


In your .bashrc put:

export GREP_COLOR=33
alias grep='grep --colour=always'


Very cool tip!! In my case, however, my .cshrc file might be a better
choice since I don't use bash, and of course the syntax is different. As
someone else pointed out the above will break scripts that use grep. A
moment or two of Googling turned up another option. If one uses
--color=auto, it will colorize output going to a terminal but won't if the
output is piped to another command or redirected to a file. The downside
is that with --color=auto output piped to less -r doesn't get colorized.
I'm sure there's a creative way to keep from breaking existing scripts and
still be able to view colorized output via less.


You can always try different values of GREP_COLOR. Although I can't seem
to get yellow.


After another moment of Googling, for yellow, use:

setenv GREP_COLOR '1;33'

or your shell's equivalent.



Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

Si hoc legere scis nimium eruditionis habes.
Longum iter est per praecepta, breve et efficax per exempla!!!


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-08-2008, 12:22 AM
Rich Healey
 
Default grep trick

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike Bird wrote:
> On Mon April 7 2008 16:03:28 Chris Bannister wrote:
>> export GREP_COLOR=33
>> alias grep='grep --colour=always'
>
> This will break any scripts which assume that the output
> of grep has not been annotated with color escape sequences.
>
> --Mike Bird
>
>
Those scripts will not load his .bashrc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH+rqwLeTfO4yBSAcRAhUUAJ4w8quP1kk2SS1vdD//MzrEe1DSkACaA5CO
tQzvjONgi0Pb2HsBgFc9034=
=62Bo
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-08-2008, 02:58 AM
Kamaraju S Kusumanchi
 
Default grep trick

Rich Healey wrote:

> Mike Bird wrote:
>> On Mon April 7 2008 16:03:28 Chris Bannister wrote:
>>> export GREP_COLOR=33
>>> alias grep='grep --colour=always'
>>
>> This will break any scripts which assume that the output
>> of grep has not been annotated with color escape sequences.
>>
> Those scripts will not load his .bashrc

The GREP_OPTIONS and GREP_COLOR environment variables created some problems
for me a while ago (See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411931 )

So instead of aliasing grep with color related options, I am currently using

if [ ! -z "$PS1" ]; then
function colgrep(){ command grep --color=always "$@"; }
fi

hth
raju
--
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-09-2008, 09:13 PM
Chris Bannister
 
Default grep trick

On Mon, Apr 07, 2008 at 06:49:20PM -0500, Kevin Monceaux wrote:
> On Tue, 8 Apr 2008, Chris Bannister wrote:
>> You can always try different values of GREP_COLOR. Although I can't
>> seem to get yellow.
>
> After another moment of Googling, for yellow, use:
>
> setenv GREP_COLOR '1;33'
>
> or your shell's equivalent.

Thanks, even works in bash, but
yeah, I found that through dircolors -p, didn't even need to go online.
>From the manpage it wasn't clear what arguments GREP_COLOR took. I
started with GREP_COLOR=brown :-) which didn't work. Then started trying
different numbers, which seemed to miss out on a few colours, so
as a thought I tried "man -k colour" ... nothing ... ...
Arrrgh, of course, "man -k color" ... yes! dircolors. But, for some reason
because "ls" didn't show any yellow I didn't click about the "1;" :-(,
also the semi colon put me off, I mean a '1;' in a script could be
problematic?

--
Chris.
======
If you are not subscribed, ask to be CC'd as the Policy of this list is
to reply to the list only.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-09-2008, 09:13 PM
Chris Bannister
 
Default grep trick

On Tue, Apr 08, 2008 at 10:22:08AM +1000, Rich Healey wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mike Bird wrote:
> > On Mon April 7 2008 16:03:28 Chris Bannister wrote:
> >> export GREP_COLOR=33
> >> alias grep='grep --colour=always'
> >
> > This will break any scripts which assume that the output
> > of grep has not been annotated with color escape sequences.
> >
> > --Mike Bird
> >
> >
> Those scripts will not load his .bashrc

Which ones? e.g ... as me:

echo $GREP_COLOR
33

less gtt
#!/bin/bash

echo $GREP_COLOR

./gtt
33

So any scripts run *as* me get it too.

--
Chris.
======
If you are not subscribed, ask to be CC'd as the Policy of this list is
to reply to the list only.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-10-2008, 09:10 AM
"Joost Witteveen"
 
Default grep trick

On 09/04/2008, Chris Bannister <mockingbird@earthlight.co.nz> wrote:
> On Tue, Apr 08, 2008 at 10:22:08AM +1000, Rich Healey wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Mike Bird wrote:
> > > On Mon April 7 2008 16:03:28 Chris Bannister wrote:
> > >> export GREP_COLOR=33
> > >> alias grep='grep --colour=always'
> > >
> > > This will break any scripts which assume that the output
> > > of grep has not been annotated with color escape sequences.
> > >
> > > --Mike Bird
> > >
> > >
> > Those scripts will not load his .bashrc
>
>
> Which ones? e.g ... as me:
>
> echo $GREP_COLOR
> 33
>
> less gtt
> #!/bin/bash
>
> echo $GREP_COLOR
>
> ./gtt
> 33
>
> So any scripts run *as* me get it too.

More precicely, any scripts you run from interactive sessions (terminal etc).
Scripts started under your UID from cron, at, etc, will not get the
GREP_COLOR var.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 04-11-2008, 03:44 PM
Osamu Aoki
 
Default grep trick

On Mon, Apr 07, 2008 at 10:58:43PM -0400, Kamaraju S Kusumanchi wrote:
> Rich Healey wrote:
>
> > Mike Bird wrote:
> >> On Mon April 7 2008 16:03:28 Chris Bannister wrote:
> >>> export GREP_COLOR=33
> >>> alias grep='grep --colour=always'
> >>
> >> This will break any scripts which assume that the output
> >> of grep has not been annotated with color escape sequences.
> >>
> > Those scripts will not load his .bashrc
>
> The GREP_OPTIONS and GREP_COLOR environment variables created some problems
> for me a while ago (See
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411931 )
>
> So instead of aliasing grep with color related options, I am currently using
>
> if [ ! -z "$PS1" ]; then
> function colgrep(){ command grep --color=always "$@"; }
> fi
>
> hth
> raju

At least in unstable:

"grep --color=auto" works nicely. So I think we can alias or use
GREP_OPTIONS='--color=auto'; export GREP_OPTIONS

Also, "GREP_COLORS" should be used instead of "GREP_COLOR".

Anyway, it was interesting.

Osamu


> Kamaraju S Kusumanchi
> http://www.people.cornell.edu/pages/kk288/
> http://malayamaarutham.blogspot.com/
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 11:18 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org