You are previewing grep Pocket Reference.

grep Pocket Reference

Cover of grep Pocket Reference by John Bambenek... Published by O'Reilly Media, Inc.
O'Reilly logo

Introduction to grep-Relevant Environment Variables

In previous examples, we came across the concept of environment variables and their effect on grep. Environment variables allow you to customize the default options and behavior of grep by defining the environment settings of the shell, thereby making your life easier. Issue an env command in a terminal to output all the current parameters. The following is an example of what you might see:

$ env

By manipulating the .profile file in your home directory, you can make permanent changes to the variables. For example, using the output just shown, suppose you decide to change your EDITOR from vi to vim. In .profile, type:

setenv EDITOR vim

After writing out the changes, this permanently ensures vim will be the default editor for each session that uses this .profile. The previous examples use some of the built-in variables, but if you are code-savvy, there is no limit (save for your imagination) on the variables you create and set.

To reiterate, grep is a powerful search tool because of the many options available to the user. Variables are no different. There are several specific options, which we describe in detail later. However, ...

The best content for your career. Discover unlimited learning on demand for around $1/day.