Computer Services & Repairs
Chicago and Suburbs
 

Table of Contents

 

7.04 Bash Keyword Variables (Environmental Variables)

Symbol

Description

BASH_ENV

The pathname of the startup file for noninteractive shells

COLUMNS

The width of the display used by select

FCEDIT

The name of the editor that fc uses by default

HISTFILE

The pathname of the file that holds the history list (default: ~.bash_history) (this variable stores most recently executed commands.)

HISTFILESIZE

The maximum number of entries saved in HISTFILE (default: 500)

HISTSIZE

The maximum number of entries saved in HISTFILE (default: 500)


Example:

[bash]$ HISTSIZE=100


HOME

Home directory

PATH

Where shell looks for programs. (each directory must be separated from the next by a colon)


Examples:

[bash]$ export PATH=/usr/local/bin:/bin:/usr/bin:~/bin: #Exporting PATH makes it value accessible to sub-shells

[bash]$ PATH=$PATH:/sbin #adds a /sbin directory as the last directory to be searched in your current path


MAIL

Where your mail is Kept

PROMPT_COMMAND

A command that bash executes just before it displays the primary prompt

PS1

User Prompt (Primary)

Options:

Formating Characters for PROMPT: (RedHat default prompt is [\u@\h\W]\$)

\! number of current command in command history

\# number of the command in the current session

\d date

\h hostname

\n newline

\s shell name

\t time

\u username

\w entire path of working directory

\W only working directory


Example:

[bash]$ PS1=”[\u@\h \w] Hello \$”;


PS2

User Prompt (Secondary). It is a secondary environmental variable. It shows up on continuation lines of command that are longer that one line

PS3

Menu Prompt

PS4

Debugging Prompt

IFS

Separates input Fields (World Splitting) # Internal Field Separator


Example:

[bash]$ a=w:x:z

[bash]$ cat $a

[bash]$ cat: w:x:z No such file or directory # Interprets the string w:x:z as a single world to be used as the argument to cat

[bash]$ IFS=”:” # IFS is set to a colon (:)

[bash]$ cat $a # shell expands the variable a into tree worlds, each of which is an argument to cat.

[bash]$ cat: w: No such file or directory

[bash]$ cat: x: No such file or directory

[bash]$ cat: z: No such file or directory

[bash]$ IFS=' \t\n' #IFS default value


INPUTRC

The path name of the Readline startup file (default: ~/.inputrc)

LANG

The locate category when that category is not specifically set with an LC_* variable

LC_*

A group of variables that specify locate categories including LC_COLLATE, LC_CTYPE, LC_MESSAGES. And LC_NUMERIC; use the locate builtin to display a complete list with values

LINES

The height of display used by select

LOGNAME

Self explanatory

CDPATH

The cd search path # if you have several directories you like to work out of, this variable can speed things up


Example:

[bash]$ export CDPATH=$HOME\:$HOME/school # the commands cause cd command to search home, school directories and then the working directory

[bash]$ CDPATH=~:/mnt/floppy/media:/mnt/cdrom #sets a search path with CDPATH variable.



 
 
   

Copyright 2006 © Burnnet Computers LLC.