Home > bashism, DOS, linux > DOS – The Default Option Set Series #1: GNU grep

DOS – The Default Option Set Series #1: GNU grep

With this post I will start an article series about default options for popular shell tools. And I would like to invite all of you to participate in this process to find a profound default option set for these tools. I will provide my current DOS as a discussion base and extend these by user comments.

In this first DOS its all about GNU grep.

Overview:

Some fundamental information about the considered tool.

Name: GNU grep
Version: 2.5.3
URL: http://www.gnu.org/software/grep/

How to set default options:

This section will describe how to set the Default Option Set. For grep its the environmental variable GREP_OPTIONS.

Default Option Set:

In this section comes a descriptive list of the options.

  • ignore binary files
    --binary-files=without-match
  • use colored output in terminals
    --color=auto
  • ignore special files like fifos, char and block devices
    --devices=skip
  • exclude patch *.rej and *.orig files
    --exclude='*.rej'
    --exclude='*.orig'
  • exclude common scm directories
    --exclude-dir=.git
    --exclude-dir=.svn
    --exclude-dir=CVS
    --exclude-dir=patches
    --exclude-dir=.pc
  • exclude build directories
    --exclude-dir=.libs
    --exclude-dir=.deps

Copy’n’Paste:

And here is a ready-to-use version of the option set.

export GREP_OPTIONS="--binary-files=without-match \
--color=auto \
--devices=skip \
--exclude='*.rej' \
--exclude='*.orig' \
--exclude-dir=.git \
--exclude-dir=.svn \
--exclude-dir=CVS \
--exclude-dir=patches \
--exclude-dir=.pc \
--exclude-dir=.libs \
--exclude-dir=.deps"

Categories: bashism, DOS, linux Tags: , ,
  1. Willi
    May 27th, 2009 at 15:21 | #1

    DOS – no pun intended – eh?
    But for real – this is a cool feature. Very usefull – another add to my bashrc – gimme more of that 😉

  2. August 5th, 2017 at 20:44 | #2

    Hello blogger, i must say you have hi quality articles here.

    Your blog should go viral. You need initial traffic only.
    How to get it? Search for: Mertiso’s tips go viral

  3. August 29th, 2017 at 07:12 | #3

    I see you don’t monetize your page, don’t waste your traffic, you can earn additional bucks every month
    because you’ve got hi quality content. If
    you want to know how to make extra $$$, search for: best adsense
    alternative Wrastain’s tools

  1. May 28th, 2009 at 09:32 | #1