Index
This index / glossary / quick-reference lists many of theimportant topics covered in the text. Terms are arrangedin approximate ASCII sorting order,modified as necessary for enhancedclarity.
Note that commands are indexedin Part 4.
* * *
^ (caret)
~ Tilde
= Equals sign
< Left angle bracket
> Right angle bracket
| Pipe, a device for passing the output of a command to another command or to the shell
|| Logical OR test operator
- (dash)
; (semicolon)
: Colon
! Negation operator, inverts exit status of a test or command
? (question mark)
// Double forward slash, behavior of cd command toward
. (dot / period)
' ... ' (single quotes) strong quoting
" ... " (double quotes) weak quoting
,
() Parentheses
[ Left bracket, test construct
[ ]Brackets
[[ ... ]] Double brackets, extended test construct
$ Anchor, in a Regular Expression
$ Prefix to a variable name
$( ... ) Command substitution, setting a variable with output of a command, using parentheses notation
` ... ` Command substitution, using backquotes notation
$[ ... ] Integer expansion(deprecated)
${ ... } Variable manipulation / evaluation
$' ... ' String expansion,using escaped characters.
Escape the character following
&
# Hashmark, special symbol beginning a script comment
#! Sha-bang, special string starting a shell script
* Asterisk
% Percent sign
+ Plus sign
* * *
Shell Variables
$_ Last argument to previouscommand
$- Flags passed to script, using set
$! Process ID of last background job
$? Exit status of a command
$@ All the positional parameters, as separate words
$* All the positional parameters, as a single word
$$ Process ID of the script
$# Number of arguments passed to a function, or to the script itself
$0 Filename of the script
$1 First argument passed to script
$9 Ninth argument passed to script
Table of shell variables
* * * * * *
-a Logical ANDcompound comparison test
Address database, script example
Advanced Bash Scripting Guide, where to download
Alias
Anagramming
And list
And logical operator &&
Angle brackets, escaped, < . . . > word boundary in a Regular Expression
Anonymous here document, using :
Archiving
Arithmetic expansion
Arithmetic operators
Arrays
Arrow keys, detecting
ASCII
awk field-oriented text processing language
* * *
Backlight, setting the brightness
Backquotes, used in command substitution
Base conversion, example script
Bash
.bashrc
$BASH_SUBSHELL
Basic commands, external
Batch files, DOS
Batch processing
bc, calculator utility
Bibliography
Bison utility
Bitwise operators
Block devices
Blocks of code
Bootable flash drives, creating
Brace expansion
Brackets, [ ]
Brackets, curly, {}, used in
break loop control command
Builtins in Bash
* * *
case construct
cat, concatentate file(s)
Character devices
Checksum
Child processes
Colon, : , equivalent to the true Bash builtin
Colorizing scripts
Comma operator, linking commands or operations
Command-line options
command_not_found_handle () builtin error-handling function(version 4+ of Bash)
Command substitution
Comment headers, special purpose
Commenting out blocks of code
Communications and hosts
Compound comparison operators
Compression utilities
continue loop control command
Control characters
Coprocesses
cron, scheduling daemon
C-style syntax , for handling variables
Crossword puzzle solver
Cryptography
Curly brackets {}
* * *
Daemons, in UNIX-type OS
date
dc, calculator utility
dd, data duplicator command
Debugging scripts
Decimal number, Bash interprets numbers as
declare builtin
Default parameters
/dev directory
Device file
dialog, utility for generating dialog boxes in a script
$DIRSTACK directory stack
Disabled commands, in restricted shells
do keyword, begins execution of commands within a loop
done keyword, terminates a loop
DOS batch files, converting to shell scripts
DOS commands, UNIX equivalents of (table)
dot files, "hidden" setup and configuration files
Double brackets [[ ... ]] test construct
Double parentheses (( ... )) arithmetic expansion/evaluation construct
Double quotes " ... " weak quoting
Double-spacing a text file, using sed
* * *
-e File exists test
echo
elif, Contraction of else and if
else
Encrypting files, using openssl
esac, keyword terminating case construct
Environmental variables
-eq , is-equal-to integer comparison test
Eratosthenes, Sieve of, algorithm for generating prime numbers
Escaped characters, special meanings of
/etc/fstab (filesystem mount) file
/etc/passwd (user account) file
$EUID, Effective user ID
eval, Combine and evaluate expression(s), with variable expansion
Evaluation of octal/hex constants within[[ ... ]]
exec command, using in redirection
Exercises
Exit and Exit status
Export, to make available variables to child processes
expr, Expression evaluator
Extended Regular Expressions
* * *
factor, decomposes an integer into its prime factors
false, returns unsuccessful (1) exit status
Field, a group of characters that comprises an item of data
Files / Archiving
File descriptors
Closing
n<&- Close input file descriptor n
0<&-, <&- Close stdin
n>&- Close output file descriptor n
1>&-, >&- Close stdout
File handles in C, similarity to
File encryption
find
Filter
Floating point numbers, Bash does not recognize
fold, a filter to wrap lines of text
Forking a child process
for loops
Functions
* * *
Games and amusements
getopt, external command for parsing script command-line arguments
getopts, Bash builtin for parsing script command-line arguments
Global variable
Globbing, filename expansion
Golden Ratio (Phi)
-ge , greater-than or equal integer comparison test
-gt , greater-than integer comparison test
groff, text markup and formatting language
Gronsfeld cipher
$GROUPS, Groups user belongs to
gzip, compression utility
* * *
Hashing, creating lookup keys in a table
head, echo to stdout lines at the beginning of a text file
help, gives usage summary of a Bash builtin
Here documents
History commands
$HOME, user's home directory
Homework assignment solver
$HOSTNAME, system host name
* * *
$Id parameter, in rcs (Revision ControlSystem)
if [ condition ]; then ... test construct
$IFS, Internal field separator variable
Integer comparison operators
in, keyword preceding [list] in a for loop
Initialization table, /etc/inittab
Inline group, i.e., code block
Interactive script, test for
I/O redirection
Indirect referencing of variables
iptables, packet filtering and firewall utility
Iteration
* * *
Job IDs, table
jot, Emit a sequence of integers. Equivalent to seq.
Just another Bash hacker!
* * *
Keywords
kill, terminate a process by process ID
killall, terminate a process by name
killall script in /etc/rc.d/init.d
* * *
lastpipe shell option
-le , less-than or equal integer comparison test
let, setting and carrying out arithmetic operations on variables
Limit string, in a here document
$LINENO, variable indicating the line number where it appears in a script
Link, file (using ln command)
List constructs
Local variables
Localization
Logical operators (&&, ||, etc.)
Logout file, the ~/.bash_logout file
Loopback device, mounting a file on a block device
Loops
Loopback devices
-lt , less-than integer comparison test
* * *
m4, macro processing language
$MACHTYPE, Machine type
Magic number, marker at the head of a file indicating the file type
Makefile, file containing the list of dependencies used by make command
man, manual page (lookup)
mapfile builtin, loads an array with a text file
Math commands
Meta-meaning
Morse code training script
Modulo, arithmetic remainder operator
Mortgage calculations, example script
* * *
-n String not null test
Named pipe, a temporary FIFO buffer
nc, netcat, a network toolkit for TCP and UDP ports
-ne, not-equal-to integer comparison test
Negation operator, !, reverses the sense of a test
netstat, Network statistics
Network programming
nl, a filter to number lines of text
Noclobber, -C option to Bash to prevent overwriting of files
NOT logical operator, !
null variable assignment, avoiding
* * *
-o Logical ORcompound comparison test
Obfuscation
octal, base-8 numbers
od, octal dump
$OLDPWD Previous working directory
openssl encryption utility
Operator
Options, passed to shell or script on command line or by set command
Or list
Or logical operator, ||
* * *
Parameter substitution
Parent / child process problem, a child process cannot export variables to a parent process
Parentheses
$PATH, the path (location of system binaries)
Pathname, a filename that incorporates the completepath of a given file.
Perl, programming language
Perquackey-type anagramming game (Quackey script)
Petals Around the Rose
PID, Process ID, an identificationnumber assigned to a running process.
Pipe, | , a device for passing the output of a command to another command or to the shell
Pitfalls
- (dash) is not redirection operator
// (double forward slash), behavior of cd command toward
#!/bin/shscript header disables extended Bash features
Abuse of cat
CGI programming, using scripts for
Closing limit string in a here document, indenting
DOS-type newlines () crash a script
Double-quoting the backslash () character
eval, risk of using
Execute permission lacking for commands within a script
Exit status, anomalous
Exit status of arithmetic expression not equivalent to an error code
Export problem, child process to parent process
Extended Bash features notavailable
Failing to quote variableswithin test brackets
GNU command set, in cross-platform scripts
let misuse: attempting to set string variables
Multiple echo statements in a function whoseoutput is captured
null variable assignment
Numerical and string comparison operators not equivalent
= and -eq not interchangeable
Omitting terminal semicolon, in a curly-bracketed code block
Piping
echo to a loop
echo to read (however, this problem can be circumvented)
tail -f to grep
Preserving whitespace within a variable, unintendedconsequences
suid commands inside a script
Undocumented Bash features,danger of
Updates to Bash breaking older scripts
Uninitialized variables
Variable names, inappropriate
Variables in a subshell, scopelimited
Subshell in while-readloop
Whitespace, misuse of
Pointers
Portability issues in shell scripting
Positional parameters
POSIX, Portable Operating System Interface / UNIX
$PPID, process ID of parent process
Precedence, operator
Prepending lines at head of a file, script example
Prime numbers
printf, formatted print command
/proc directory
Process
Process substitution
Programmable completion (tab expansion)
Prompt
Pseudo-code, as problem-solving method
$PWD, Current working directory
* * *
Quackey, a Perquackey-type anagramming game (script)
Question mark, ?
Quoting
* * *
Random numbers
rcs
read, set value of a variable from stdin
readline library
Recursion
Redirection
Reference Cards
Regular Expressions
$REPLY, Default value associated with read command
Restricted shell, shell (or script) with certain commands disabled
return, command that terminates a function
run-parts
* * *
Scope of a variable, definition
Script options, set at command line
Scripting routines, library of useful definitions and functions
Secondary prompt, $PS2
Security issues
sed, pattern-based programming language
select, construct for menu building
Semaphore
Semicolon required, when do keyword is on first line of loop
seq, Emit a sequence of integers. Equivalent to jot.
set, Change value of internal script variables
Shell script, definition of
Shell wrapper, script embedding a command or utility
shift, reassigning positional parameters
$SHLVL, shell level, depth to which the shell (or script) is nested
shopt, change shell options
Signal, a message sent to a process
Simulations
Single quotes (' ... ') strong quoting
Socket, a communication node associated with an I/O port
Sorting
source, execute a script or, within a script, import a file
Spam, dealing with
Special characters
Stack
Standard Deviation, example script
Startup files, Bash
stdin and stdout
Stopwatch, example script
Strings
Strong quoting ' ... '
Stylesheet for writing scripts
Subshell
su Substitute user, log on as a different user or asroot
suid (set user id) file flag
Symbolic links
Swapfiles
* * *
Tab completion
Table lookup, script example
tail, echo to stdout lines at the (tail) end of a text file
tar, archiving utility
tee, redirect to a fileoutput of command(s) partway through a pipe
Terminals
test command
Test constructs
Test operators
-a Logical ANDcompound comparison
-e File exists
-eq is-equal-to (integer comparison)
-f File is a regularfile
-ge greater-than or equal (integer comparison)
-gt greater-than (integer comparison)
-le less-than or equal (integer comparison)
-lt less-than (integer comparison)
-n not-zero-length(string comparison)
-ne not-equal-to (integer comparison)
-o Logical ORcompound comparison
-u suidflag set, file test
-z is-zero-length(string comparison)
= is-equal-to (string comparison)
== is-equal-to (string comparison)
< less-than (string comparison)
< less-than, (integer comparison, within double parentheses)
<= less-than-or-equal, (integer comparison, within double parentheses)
> greater-than (string comparison)
> greater-than, (integer comparison, within double parentheses)
>= greater-than-or-equal, (integer comparison, within double parentheses)
|| Logical OR
&& Logical AND
! Negation operator, inverts exit status of a test
!= not-equal-to (string comparison)
Tables of test operators
Binary comparison
File
Text and text file processing
Time / Date
Timed input
Tips and hints for Bash scripts
Array, as return value froma function
Capturing the return value of a function, usingecho
CGI programming, using scripts for
Comment blocks
Using anonymous here documents
Using if-thenconstructs
Comment headers, special purpose
C-style syntax , for manipulating variables
Double-spacing a text file
Filenames prefixed with a dash, removing
Filter, feeding output back to same filter
Function return valueworkarounds
if-grep test fixup
Library of useful definitions and functions
null variable assignment, avoiding
Passing an array to a function
$PATH, appending to, using the += operator.
Prepending lines at head of a file
Progress bar template
Pseudo-code
rcs
Redirecting a testto /dev/null to suppress output
Running scripts in sequence without user intervention, using run-parts
Script as embedded command
Script portability
Setting path and umask
Using whatis
Setting script variableto a block of embedded sed orawk code
Subshell variable, accessing outside the subshell
Testing a variable to see if it contains only digits
Testing whether a command exists, using type
Tracking script usage
while-read loop without a subshell
Widgets, invoking from ascript
$TMOUT, Timeout interval
Token, a symbol that may expand to a keyword or command
tput, terminal-control command
tr, character translation filter
Trap, specifying an action upon receipt of a signal
Trinary (ternary) operator, C-style, var>10?88:99
true, returns successful (0) exit status
typeset builtin
* * *
$UID, User ID number
unalias, to remove an alias
uname, output system information
Unicode, encoding standard for representing letters and symbols
Uninitialized variables
uniq, filter to remove duplicate lines from a sorted file
unset, delete a shell variable
until loop
until [ condition-is-true ]; do
* * *
Variables
* * *
wait, suspend script execution
Weak quoting " ... "
while loop
while [ condition ]; do
Whitespace, spaces, tabs, and newline characters
who, information about logged on users
Widgets
Wild card characters
Word splitting
Wrapper, shell
* * *
xargs, Filter for grouping arguments
* * *
yes
* * *
-z String isnull
Zombie, a process that has terminated, but not yet been killed by its parent