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 USER=user LOGNAME=user HOME=/home/user PATH=/usr/local/sbin:/usr/local/bin:/usr /sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:. SHELL=/usr/local/bin/tcsh OSTYPE=linux LS_COLORS=no=0:fi=0:di=36:ln=33:ex=32 :bd=0:cd=0:pi=0:so=0:do=0:or=31 VISUAL=vi EDITOR=vi MANPATH=/usr/local/man:/usr/man:/usr /share/man:/usr/X11R6/man ...
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
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, ...