x32x01
  • by x32x01 ||
List of All Bash Environment Variables
List of All Bash Environment Variables
A shell is a program that runs operating system commands. Bash has more than 50 predefined variables.These variables, created when Bash is first started, provide information about the Bash session and can be used to control some of the shell’s features.

Some of these variables have special properties that might be lost if you unset the variable and then create a new one with the same name.

For example, the variable RANDOM contains a random number. If you delete RANDOM with unset and declare a new variable called RANDOM, this new variable is a normal shell variable and does not contain random numbers.Therefore, it’s best to avoid creating variables with the same name as the predefined variables.

Environment variables are the variables Linux shares between a program and the program that executed it. Like layers of an onion, each program must explicitly export a variable into the environment for the next program to see it.

Here we’ve listed out all Bash Environment Variables which are as follows:
$*Contains all of the command line parameters as a single text value.
$@Contains all of the command line parameters as separate text values.
$#The number of command line parameters.
$?The exit status of the most recently used foreground process.
$-The current command line option flags.
$$The process ID (PID) of the current shell.
$!The PID of the most recently executed background process.
$0The name of the command from the command line.
$The absolute pathname of the shell.
BASHThe full filename used to invoke the shell.
BASH_ARGCThe number of parameters in the current subroutine.
BASH_ARGVAn array containing all of the command line parameters specified.
BASH_COMMANDThe name of the command currently being executed.
BASH_ENVWhen set, each bash script attempts to execute a startup file defined by this variable before running.
BASH_EXECUTION_STRINGThe command used in the -c command line option.
BASH_LINENOAn array containing the line numbers of each command in the script.
BASH_REMATCHAn array containing text elements that match a specified regular expression.
BASH_SOURCEAn array containing source filenames for the declared functions in the shell.
BASH_SUBSHELLThe number of subshells spawned by the current shell.
BASH_VERSIONThe version number of the current instance of the bash shell.
BASH_VERSINFOA variable array that contains the individual major and minor version numbers of the current instance of the bash shell.
COLUMNSContains the terminal width of the terminal used for the current instance of the bash shell.
COMP_CWORDAn index into the variable COMP_WORDS, which contains the current cursor position.
COMP_LINEThe current command line.
COMP_POINTThe index of the current cursor position relative to the beginning of the current command.
COM_WORDBREAKSA set of characters used as word separators when performing word completion.
COMP_WORDSA variable array that contains the individual words on the current command line.
COMPREPLYA variable array that contains the possible completion codes generated by a shell function.
DIRSTACKA variable array that contains the current contents of the directory stack.
EUIDThe numeric effective user ID of the current user.
FCEDITThe default editor used by the fc command.
FIGNOREA colon-separated list of suffixes to ignore when performing filename completion.
FUNCNAMEThe name of the currently executing shell function.
GLOBIGNOREA colon-separated list of patterns defining the set of filenames to be ignored by filename expansion.
GROUPSA variable array containing the list of groups of which the current user is a member.
histcharsUp to three characters that control history expansion.
HISTCMDThe history number of the current command.
HISTCONTROLControls what commands are entered in the shell history list.
HISTFILEThe name of the file to save the shell history list (.bash_history by default).
HISTFILESIZEThe maximum number of lines to save in the history file.
HISTIGNOREA colon-separated list of patterns used to decide which commands are ignored for the history file.
HISTSIZEThe maximum number of commands stored in the history file.
HOSTFILEContains the name of the file that should be read when the shell needs to complete a hostname.
HOSTNAMEThe name of the current host.
HOSTTYPEA string describing the machine the bash shell is running on.
IGNOREEOFThe number of consecutive EOF characters the shell must receive before exiting. If this value doesn’t exist, the default is one.
INPUTRCThe name of the Readline initialization file (the default is .inputrc).
LANGThe local category for the shell.
LC_ALLOverrides the LANG variable, defining a local category.
LC_COLLATESets the collation order used when sorting string values.
LC_CTYPEDetermines the interpretation of characters used in filename expansion and pattern matching.
LC_MESSAGESDetermines the local setting used when interpreting double-quoted strings preceded by a dollar sign.
LC_NUMERICDetermines the local setting used when formatting numbers.
LINENOThe line number in a script currently executing.
LINESDefines the number of lines available on the terminal.
MACHTYPEA string defining the system type in cpu-company-system format.
MAILCHECKHow often (in seconds) the shell should check for new mail (default is 60).
OLDPWDThe previous working directory used in the shell.
OPTERRIf set to 1, the bash shell displays errors generated by the getopts command.
OSTYPEA string defining the operating system the shell is running on.
PIPESTATUSA variable array containing a list of exit status values from the processes in the foreground process.
POSIXLY_CORRECTIf set, bash starts in POSIX mode.
PPIDThe process ID (PID) of the bash shell’s parent process.
PROMPT_COMMANDIf set, the command to execute before displaying the primary prompt.
PS1The primary command line prompt string.
PS2The secondary command line prompt string.
PS3The prompt to use for the select command.
PS4The prompt displayed before the command line is echoed if the bash-x parameter is used.
PWDThe current working directory.
RANDOMReturns a random number between 0 and 32767. Assigning a value to this variable seeds the random number generator.
REPLYThe default variable for the read command.
SECONDSThe number of seconds since the shell was started. Assigning a value resets the timer to the value.
SHELLOPTSA colon-separated list of enabled bash shell options.
SHLVLIndicates the shell level, incremented by one each time a new bash shell is started.
TIMEFORMATA format specifying how the shell displays time values.
TMOUTThe value of how long (in seconds) the select and read commands should wait for input. The default of zero indicates to wait indefinitely.
UIDThe numeric real user ID of the current user.
 

Similar Threads

x32x01
  • x32x01
Replies
0
Views
180
x32x01
x32x01
x32x01
Replies
0
Views
77
x32x01
x32x01
x32x01
Replies
0
Views
111
x32x01
x32x01
x32x01
Replies
0
Views
99
x32x01
x32x01
x32x01
Replies
0
Views
85
x32x01
x32x01
TAGs: Tags
bash environment variables

Register & Login Faster

Forgot your password?

Latest Resources

Forum Statistics

Threads
517
Messages
518
Members
44
Latest Member
Zodiac
Back
Top