Cover | Table of Contents | Colophon
[ Numbers and Symbols ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Y ], [ Z ],
Numbers and Symbols[ Top ]
- dash, 392
! exclamation point, 11
- operations, 298
!! double exclamation point (bang bang), 150, 456
!$ exclamation, dollar sign, 459
" double quotes, 12, 30, 254
# pound, 82
# pound, trailing, 4
#!, and finding bash, 321
#!/bin/sh, 321
$ dollar sign, 29, 81, 109, 153
$ dollar sign, trailing, 4
$- syntax, lists current shell option flags, 15
$$ double dollar sign, 243
$( ) (see also ``), 147
$( ) dollar sign, parentheses, 46
$(( )) expression, 108
$* dollar, asterisk, 91
$? dollar sign, question mark, 74
$@ dollar, at sign, 94
${!prefix*}, for parameters programmable completion, 287
${!prefix@}, 287
${#} dollar sign, bracket, pound sign, bracket, 96, 248
${#VAR}, 97
${:=} syntax, 101
${:?} syntax, 103
${:-} syntax, 99
${1:0:1} syntax, 248
${parameter#[#]word}, 480
${parameter%[%]word}, 480
${parameter/pattern/string}, 480
${VAR#alt}, 97
${variable/pattern/replacement}, 195
$0 variable, 236
$COMP_WORDS, 393
$COMPREPLY, 393
$cur variable, 393
$FUNCNAME, 206
$HISTCONTROL, 378
$HISTFILE, 378
$HISTFILESIZE variable, 378
$HISTIGNORE, 378
$HISTSIZE, 378
$HISTTIMEFORMAT, 378
$i, don't use (see also $x), 85
$i, use of, in awk, 157
$IFS (bash Internal Field Separator), 287
$IFS=':', 196
$include (readline), 201, 373
$INPUTRC, 371
$LESS variable, 182
$LESSCLOSE, 182
$LESSOPEN, 182
$PASSWD, 65
$PATH, 6, 68, 195, 283, 361, 362-366
$PROMPT_COMMAND, 359
$PS1, 353, 357, 410
$PS2, 353, 374
$PS3, 357, 374
$PS4, 357, 376
$PWD, 358
$RANDOM, 292
$REPLY, 64
$result, 341
$SCRIPT, 79
$SSH_ID, 341
$SSH_USER, 341
$STAT, 70
$temp_dir, 293
$TMOUT variable, 318
$UMASK variable, 288
$UNZIP, 78
$VERBOSE, 98
$x, don't use (see also $i), 85
$ZIP, 78
% percent sign, 31
& ampersand, 72
&& double-ampersands, 72
&> ampersand, greater than sign, 38
'{}', holds filenames during command execution, 193
( ) parentheses, 42, 190
(( )) double parentheses, 127
(-) dash, 40
* asterisk, 9, 10, 121
** double asterisk, 109
*.pub public key, 309
*.txt, for pattern matching, 11
+ operations, 298
+ plus sign, 40
, comma operator, 110
. dot, 68, 201
. dot files, 11
. period, 152
.* period, asterisk, 10, 152
./ leading dot
slash character, 7
./ leading dot and slash character, 69
.[!.]*, 11
.bash.0, 27
.deb files (see also .rpm), 173
.FAQ, 26
.html, 27
.INTRO, 26
.jpg, 121
.ps, 27
.rbash.0, 27
.rpm (see also .deb files), 173
/ slash, 35, 105
/ slash with -F, 9
/bin/bash, 370
/dev/nul, 148
/etc/bash.bashrc, 395
/etc/bash_completion, 395
/etc/bashrc, 395, 401
/etc/inputrc, 395
/etc/passwd file, 16
/etc/profile, 395, 400
/etc/shells, 20
/etc/shells, list of valid shells, 16
/proc/core for accessing passwords, 65
/sbin/ifconfig -a, 338
/tmp for scratch directory, 35
/tmp/ls, 292
/usr partition, 17
/usr/bin/env command, 321
:- assignment operator, 101
: colons, 68
:+ variable operator, 203
:= colon, equal sign, 102
; semicolon, 72, 112
< less than symbol, 55
<<- syntax, 59
<= greater than, equal sign, 240
<a> tags, 253
= (or ==), for string comparisons, 119
= equal sign, 81, 109
== double equal signs, 240
> greater than sign, 33, 48, 55
>& greater than sign, ampersand, 38
>> double greater than, 39, 115
>outputfile, 29
? question mark, 121
?, shell pattern matching operator, 11, 514
@ at sign, 9, 203
[ [ ] ] double bracket, 121
[ ] single brackets, 10, 126, 152
[ bracket, 10
\ backslash, 152, 153
\ leading backslash, 285
\; backslash, semicolon, 193
\<inputfile, omitting allows output to go anywhere, 29
\{n,m\}, for repetition (regular expressions), 153
\c, for echo escape sequence, 33
\unalias -a command, 285
\w, 358
\W, to print basename, 358
^ caret, 11, 153
_mcd_command_failed_, 382
_signals, 393
_struct, 385
`` backward quotes (see also $( )), 46
{ } braces, 42
{{ }} double braces, code block, 341
{x..y} brace expansion, 449
| (vertical bar) pipe
' single quote, 12, 30, 152, 254, 535
|| double pipes, 77
pipe characters (|), 532
pipe symbol (|)
pipeline, 532
~ tilde, 4
~/.bash_history, 395
~/.bash_login, 395
~/.bash_logout, 395
~/.bash_profile, 395
~/.bashrc, 395
~/.inputrc, 396
~/.profiles, 395
~/bin directory, 373
0m, clears all attributes and set no color, 360
-1 option, 9
A[ Top ]
-a flag, 6
-a operator, 9, 115
-A option (mkisofs), 244
absolute pathname, 35
absolute paths, hardcoding, 284, 362
accessing data, on remote machines, 307
accounts, shared, 302
Add/Remove Applications, 19
adding directories, 362
Advanced Bash-Scripting Guide, 27
AIDE, 282
AIX, 22
aliases
avoiding, 213
clearing, 285
commands, redefining with, 211
expand_aliases, 370
expansion, suppressing with \ leading backslash, 285
Host_Alias, 306
malicious, 285
processing on command line, 534
' (single quote) with, 212
recursive, 534
\unalias -a command, 285
User_Alias, 306
ampersand (&) to run commands in the background, 72
AND (-a), 117
AND constructs, 190
ANSI color escape sequences, 484
ANSI escape sequence, 355, 359
AppArmor, 304
application directories, 362
Application Software for NetBSD, 20
apropos, searches manpage for expressions, 7
archives, 22, 388
ar archives, 173
Archive Center, 22
archiving data, 421
untaring, 175
ARG_MAX, 344
arguments
${ } syntax for variables, 105
$VERBOSE, 98
breaking up, 343
cd (current directory) command, 368
counting, 96
getopts, 249-252
insufficient, 104
list too long error, 343
looping over, 91
options with, 98, 249
parsing, 134, 231, 248
positional parameters, 101
quotes, around file, 411
real arguments, 98
repeat without retyping, 460
reusing, 458
-v argument, 98
arithmetic
$ (dollar sign), 109
$(( )) expression, 108
** (double asterisk), for raising to a power, 109
assignment operators, 109
comma operator (,), 110
dates and times, 225
equal sign (=), 109
expansion, 103
integer expressions, 108
integer for loops, 449
let statement, 108
operators, 109
spaces, 109
while looping construct, 126
arithmetic expressions
evaluation of, 534
arrays
initialization of, 107, 255
output, parsing into, 255
single-dimension, 106
variables, using, 106, 123
article.ms, bash article, 26
assignment operators, 109
associative arrays (hashes in awk), 159
asterisk
*dollar, asterisk, 91
in strings, 10
match any number of characters, 121
means file is executable, 9
means to repeat zero or more occurrences, 152
at sign (@), 9, 203
attacker, non-root, 293
attacks, man in the middle, 315
automating processes, 348-351
available space, tracking on MP3 players, 238
awk
awk command, 265
awk program, 157
awk utility, 155
to split on multiples of whitespace, 265
B[ Top ]
backslash (\), 12, 153
backslash, semicolon (\;), 193
backup directories, 439-442
backward quotes (``) (see also $( )), 46
bad line endings, 464
Barrett, Daniel, 308, 316
basename command, 136
bash, 16
bash --version, checks for bash installation, 16
built-in umask, 288
documentation, 25
environment replication, 398
functions, 203
installation instructions, 26
Ramey, Chet, 21, 25
redirector, 39
session, sharing a single, 417
tarballs, 297
version 3.0, for pattern matching, 123
version 3.1+, for changing case sensitivity, 124
bash $IFS (Internal Field Separator), 254, 258, 268, 270
bash invocation, 482
bash.1, manpage, 26
bashbug.0, manpage formatted, 27
bashbug.1, bashbug manpage, 26
bash-completion library, list of modules, 390
bashgetopt.h, 387
bash_logout, sample of, 408
bash_profile, sample of, 401
bashrc, sample of, 403
bashref, Bash Reference Guide, 27
bashref.info, reference manual by makeinfo, 26
bashref.texi, reference manual, 26
bashtop, 25
batch job, logging, 418
bdiff, 437
Beagle, desktop search engine, 194
Beebe, Nelson H.F., 281
BEGIN keyword (awk), 158
bg, to unpause the job, 73
bin directory, 69
bind commands, 372
bit buckets, 148
bits, take away from default permissions, 288
blank spaces, 109
blanks, embedded, 92
blocks, 192
Boolean flags, 202
Bourne shells, /etc/profile, global login environment file, 395
brace expansion, 534
braces ({ }), 42, 87, 91
bracket ([), in strings, 10
branching construct, 111
branching, multiway, 132
Browser Appliance v1.0.0, 326
browser, viewing photos with, 233
BSD, 20, 325
buffer overflows, 282
built-in commands
bash, network redirection feature, 345
BUILTIN_ENABLED, 385
builtin_name, 385
builtins.0, built-ins manpage, 27
builtins.1, 26
builtins.h, 387
C code, 385
commands, replacing, 13
turn off commands, 14
description structure, 385
enable -a, lists commands, 14
enable command, 14
enable -n, turns off shell commands, 14
./examples/loadables/, 384
help command, 14
loadables, 384
loading, 385
memory and conserving when loading, 389
popd command, 454
pushd command, 454
pwd (print working directory command), 5
shell cd, using, 382
shell functions and aliases, ignoring, 213
shift command, 135
test command, 118
textual completion, extending, 391
tty command, 385
unmask, 288
writing, 385
bytes, 192
bzip2, file compression, 172
C[ Top ]
C header files, 387
-c option (grep), 146
cached SSH keys, flushing, 313
call by value, 88
canonical portable syntax for bash $IFS, 287
caret (^), 11, 153
case, identify options, 248
case-insensitive search, 57, 149
case sensitivity, 133, 177
case statement, 132, 232, 250, 349
cat command, 34, 72, 236
cat program, 244
cdAnnotation, 244
cd (current directory) command, 42, 74, 214, 368, 380-381
cdrecord, 242
CDs, burning, 242
CentOS, 19, 170
CHANGES, bash change history, 26
changing command names, 369
changing directories, 381
changing the exported value, 88
characters
asterisk (*), match any number of, 121
backslash (\), matches special, 153
caret (^), to negate character class, 11
counting, 180
-d option (cut), specify delimiters, 178
-d option (tr), for deleting, 178
default, for paper and screen, 85
exclamation point (!) to negate class, 11
for enclosed non-printing, 355
leading with, other than a tab, 60
odd characters in file names, 186
parsing one at a time, 260
patterns for matching, 152
pound (#), 82
question mark (?), for matching a single character, 121
renaming or removing files with special, 428
space characters, 92
tabs, 59
tr command, for translation of, 176
translation of, 176
unprintable, 333
whitespace, 333
chmod, 298
choice function, prompts for and verify a package date, 62
chpass -s shell, changes default shell, 16
chroot command, 303
chroot Jails, 303
chroot, and system recovery, 304
chsh -l, lists valid shells, 16
chsh -s /bin/bash, makes bash default shell, 16
chsh -s, changes default shell, 16
chsh, opens editor, 16
Classic Shell Scripting (O'Reilly), 25, 281
--clean option, flushes cached SSH keys, 313
clear command, 420
clear, using with traps, 410
clobber a file, 53
cmdhist, 379
Cmnd_Alias (sudo), 306
cmp, 427
code, running interactively, 15
colon, equals sign (:=), 102
colons (:), to separate directories, 68
color escape sequence, and trailing m, 360
comm, 438
comma operator (,), 110
Comma Separated Values (CSV), 277
command
changing a typo in, 456
command, 197, 213, 324, 382
eval command, 536
exit status ($?), 70
for compiling and linking, 388
hash, 286
line calculator, 142
lines, repeating, 455
names, changing or shortening, 369
not found errors, 204, 468, 479
command (continued)
number, 359
-p, 324
quoting affecting, 535
redefine with alias, 211
run several in sequence, 71
running in the background, 73
separating with semicolons, 72
substitution, 103, 340
using sudo on several, 434
verify success of, 69, 74
command-line processing
repeating, 536
commas, as the thousands separator, 452
comments, 82, 97, 309
comparison operators, 120
COMPAT, compatibility issues, 26
compgen, 392, 393, 481
complete command, 391, 481
completion strings, viewing, 392
compound commands, 114
compressed archives, uncompressing, 391
compressed files, 154, 172
compression algorithms, 173
config.h, 387
configuration and customization
$CDPATH directories, 367-368
$COMP_WORDS, 393
$COMPREPLY, 393
$cur variable, 393
$HISTCONTROL, 378
$HISTFILE, 378
$HISTFILESIZE variable, 378
$HISTIGNORE, 378
$HISTSIZE, 378
$HISTTIMEFORMAT, 378
$include, 373
$INPUTRC, 371
$PATH, 362-366
$PATH, change permanently, 361
$PROMPT_COMMAND, 359
$PS1, command prompt, 353, 357
$PS1, errors with, 410
$PS2, 353, 374
$PS3, select prompt, 357, 374
$PS4 prompt, 376
$PWD, to print entire CWD, 358
/etc/bash.bashrc (Debian), global environment file, 395
/etc/bash_completion, for programmable completion library, 395
/etc/bashrc (Red Hat), bash sub-shells global environment file, 395
/etc/bashrc, for system-wide environment settings, 401
/etc/inputrc, for global GNU Readline configuration, 395
/etc/profile, Bourne shells global login environment file, 395
/etc/profile, system-wide profile settings, 400
\W, to print basename, 358
\w, to print entire path, 358
_mcd_command_failed_, 382
_signals, 393
_struct, 385
~/.bash_history, command history default storage file, 395
~/.bash_login, for Bourne login shells personal profile files, 395
~/.bash_logout, 395
~/.bash_profile, for bash login shells personal profiles, 395
~/.bashrc, for bash sub-shells personal environment files, 395
~/.inputrc, for GNU Readline customizations, 396
~/.profile, for Bourne logging shells personal profile files, 395
~/bin directory, 373
0m, clears all attributes and set no color, 360
absolute paths, hardcoding, 362
alias, 369
ANSI, 359
ANSI escape sequence, 355
application directories, 362
archive, 388
bash -c help, 353
bash-completion library, list of modules, 390
bash environment, replication, 398
bashgetopt.h, 387
bash --help, 353
bash login rc files, 396
bash_logout, sample of, 408
bash_profile, sample of, 401
bashrc, sample of, 403
bash -x, 353
bind commands, 372
built-in
commands, 382
list of loadables, 385
memory and conserving when loading, 389
textual completion, extending, 391
writing, 385
BUILTIN_ENABLED, 385
builtin_name, 385
builtins.h, 387
C code, 385
C header files, 387
cd argument, 368
clear, using with traps, 410
cmdhist, 379
command
command, 382
names, changing or shortening, 369
number, 359
compgen, 392, 393
complete command, 391
completion strings, viewing, 392
compressed archives, uncompressing, 391
config.h, 387
configuration files, using in bash scripts, 202
configure script, 388
Ctrl-X P, displays $PATH, 362
beginning custom configuration, 400
CWD (current working directory), 358
description structure, for built-ins, 385
directories, creating and changing in one step, 381
directories, using find command in many levels, 383
downloads for this book, 356
dynamic shared objects, 388
echo statements, care when using, 399
egrep pattern, 363
enable built-in, 385
enclosed non-printing characters, 355
environment settings, system-wide, 401
erasedups, 378
error messages, identifying, 366
EX_USAGE, 386
./examples/loadables/, for pre-written built-ins, 384
EXECUTION_FAILURE, 387
EXECUTION_SUCCESS, 387
exit code, 363
exit status ($?), 354
expand_aliases, 370
export command, 357
Fedora Core 5, 353
function-name, 385
functions, 369
grep -l PATH ~/.[^.]*, 361
gunzip utility, 391
hello.c, 384
help_array, 385
histappend, 379
history, between sessions and synchronization, 376
history command, 376
history number, 359
history options, setting, 377
history sharing, automation of, 377
if command, 363
ignoreboth, 378
ignoredups, 378
ignorespace, 378
improving cd commands, 380
.inputrc, 371
inputrc, sample of, 407
internal_getopt, 387
jobs, number being currently managed, 354
kill command, 392
leading dots in filenames, 398
libraries, third-party, 389
lithist, 379
loadable built-ins, 384
loptend, 387
macros, for shell interaction documentation, 362
Makefile, 384
Meta Ctrl-V, displays variable for editing, 362
mkdir command, 382
no_options(list), 386
NULL, 387
options, 353
PATH="$PATH:newdir", 362
paths, 361, 362, 366
personal utilities, 373
POSIX mode, 368
profile settings, system-wide, 400
programmable completion, 389
prompts, 353, 355, 359
prompt strings, 357
promptvars shell option, 357
PTY, pseudo-terminal number, 354
RC (initialization) files, 394, 398-400
readline, 362, 371
reset_internal_getopt, 387
root, set paths, 361
configuration and customization (continued)
run_screen, sample of, 408
-s option (example loadable built-in), 385
secondary prompts, 374
select statement, 374
settings subdirectory, 398
set +x, 353
shell.h, 387
shells, levels of, 354
signal names, 392
startup options, 353
stdio.h, 387
strftime, 378
symbolic links, 370
trailing m, indicates color escape sequence, 360
tty built-in, 385
ttyname, 387
unalias, 369
usage, short form of help, 386
WORD_LIST, 386
world-writable directory, avoid in root's path, 361
xterms, 355, 359
xtrace, for debugging prompt, 357
configuration files, 200-203
configure script, 388
continue statement, 163
converters, for documents, 414
converting dates and times to Epoch seconds, 222
converting Epoch seconds to human-readable dates and times, 223
Conway, Damian, 84
Copernic Desktop Search, 194
core dumps, 65, 287
CPIO files, 173
creating directories, 381
creating RC files, 398-400
cron, 228, 347
cron jobs, and passwords, 308
cross-platform scripts, 326
crypt hashes, 307
CS_PATH, 323
C strftime( ) function (man 3 strftime), for formatting options, 217
CSV (Comma Separated Values), 277, 278
Ctrl-A K, to kill the window and end the session, 418
Ctrl-X P, displays $PATH, 362
cur_weekday, 222
curl, 336
current working directory, 358
custom configuration, introduction to, 400
cut command, 170, 264
CWD (current working directory), 358
Cygwin, 23
cygwin1.dll, 23
D[ Top ]
D/M/YY formats, avoid, 218
-d option (date)
-d option, 170, 219, 221
-d option (cut) specify delimiters, 178
-d option (tr), 178
daemon, 199
dash (-), 40, 392
dash, shell, 324
dashes, print a line of, 230
data
accessing on remote machines, 307
archiving, 421
files, updating specific fields, 266
fixed-length, 273
fixed-width, 273
isolating fields, 264
numeric, 166
prepending, 429-432
subsets, 170
validation, 282
databases, setup with MySQL, 262
dates and times
%z format, 218
arithmetic, 225
C strftime( ) function (man 3 strftime), for formatting options, 217
converting to specific day and time, 223
crons, 228
crontab, 228
cur_weekday, 222
-d option, 219, 221
D/M/YY formats, avoid, 218
date command, 216
date ranges, automating, 220
DAY, caution using, 221
Daylight Saving Time, 227
day, ranges, 229
day of week for the given day, 222
DD/MM/YY formats, avoid, 218
default dates, 218
end of month of the given month, 222
end_month, 222
Epoch seconds, 222, 223, 227
formatting options, 217
gawk, 216
getdate, 220
GNU date command, 216, 219, 221, 224
ISO 8601, displays dates and times, 218
leap years, 226, 227
Linux Vixie Cron, 228
M/D/YY formats, avoid, 218
MM/DD/YY formats, avoid, 218
NTP (Network Time Protocol), 226
number of days between two dates, 222
Perl, 223, 224, 227
pn_day, 222
pn_day_nr, 222
pn_month, 222
pn_weekday, 222
previous and next x days of the given day, 222
previous and next x months, 222
scripts, running on Nth day, 228
seconds, 226, 227
SQL query, 219
strftime format specification, 217
string formatting with strftime, 513
this week, caution using, 221
time zones, 218, 226
tomorrow's, 224
Unix command, omits the year, 226
UnixReview, 221
DAY, caution using, 221
Daylight Saving Time, 227
day of week for the given day, 222
DD/MM/YY formats, avoid, 218
Debian, 17, 173, 183, 197
DEBUG signal, 210
debugging, and core dumps, 287
declare option, 210
default dates, 218
default values, 99, 100
deleting characters, 178
delimiters, 170
description structure, for built-ins, 385
desktop search engine, 194
developerWorks (IBM), 313
diff, 246, 422-425, 437
digit octal modes, 298
direct parsing, ${#} dollar sign, bracket, pound sign, bracket, 248
directories, 361
$CDPATH directories, 368
$PATH errors, 465
add or remove, 362
adding current to $PATH, 291
application, 362
backups of, 439-442
colons (:), to separate, 68
creating and changing in one step, 381
find command, using in many levels, 383
moving among arbitrary ones, 453
names, parsing off, 175
photos, viewing, 232
relative, 173
tar archives, 175
temporary, 282
world-writable, 289-291, 361
disconnected sessions, 415
display variables for editing, 362
divert output, 47
documentation, 25, 83, 362
documents, comparing, 244
dollar sign ($), 29, 81, 109, 153
variable substitution, 534
dollar sign, brace, pound sign, brace (${#}), 96
dollar sign, parentheses ($( )), for command substitution, 46
dollar, asterisk ($*), 91
dollar, at sign ($@), 94
DOS
carriage returns (\r), deletion, 178
endlines, converting to Unix, 173
files, convert to Linux, 178
pause command, 450
dos2unix, 464
dot (.) files, 10, 11, 201
dot directory, 68
double asterisk (**), for raising to a power, 109
double braces ({{ }}) code block, 341
double bracket compound statement ([ [ ] ]), 121
double dollar sign variable ($$), 243
double equals signs (==), 240
double exclamation point (!!) history operator, 150
double greater than operator (>>), 115
double parentheses ((( ))) construct, 127
double quotes ("), 30, 254, 535
double-ampersands (&&), 72
downloads for this book, 356
duplicate lines, removing, 171
dynamic shared objects, 388
E[ Top ]
-e option, escape sequence (echo), 33
echo *, ls command substitute, 11
echo command, 29, 32, 70, 214, 329-331
echo options and escape sequences, 508
echo portability, 329
echo statements, care when using, 399
ed script, 433
egrep, 265, 363
egress filtering, 337
elif, 111
else clause, 111
else-if (elif), 111
Emacs and vi, allow shell escapes, 303
Emacs mode commands, 518
email, sending, 345-348
embedded blanks, 92
embedding documentation, in shell scripts, 83
EMIT function, 236
empty variables, 474
enable -a, lists built-in commands, 14
enable built-in, 385
enable command, 14
enable -n, turns off shell built-in commands, 14
end of month, 222
END keyword (awk), 158
end_month, 222
endlines, converting to Unix to DOS, 173
end-user documentation, 83
env (export -p), 88
env command, 321
environment settings, system-wide, 401
EOF (end-of-input word), 237
end-of-input word (EOP), 237
Epoch seconds, 222, 223, 227
eq operator, 120
-eq operator, for numeric comparisons, 119
equal sign (= sign), 109
erasedups, 378
ERR signal, 210
error messages, 37, 77, 103, 251, 366
errors, and core dumps, 287
ERROUT function, 236
escape sequences, 33, 179
eval command, 536
EX_USAGE., 386
./examples/loadables/, 384
exclamation point (!) to negate character class, 11
-exec, 185
exec command, 335, 342
exec option, 193
executables
$PATH, 68
$SCRIPT, 79
$STAT, 70
. (dot) with ls, supersedes normal ls command, 68
./ (leading dot and slash character), 69
|| syntax, for error/debug messages, 77
ampersand (&) to run commands in the background, 72
asterisk (*), 9
bg, to unpause the job, 73
bin directory, 69
cd command, 74
colons (:), to separate directories, 68
commands, 69, 71, 72, 74
conditional execution, of if statement, 75
dot directory, 68
double-ampersands (&&), to run the next program, 72
echo command, 70
error messages, 77
executePermissions, forgetting to set, 462
exit, 70
exit status ($?), 70, 74
fg command, reconnects to a background job, 73
file permissions, 69
for looping, 67
hangup (hup) signal, 76
if statement, 71, 74, 75
if/then/else branching, 67
InfoZip, 78
job number, 73
jobs, running unattended, 76
kill command, 76
locate executables, 68
nohup command, 76
Permissions, forgetting to set execute, 462
PID (process ID, $$), 73
rm command, 74
run a command, 67
scripts, running a series of, 79
set -e flag, 76
variable names, use with care, 78
variables, running commands from, 78
while loops, 75
EXECUTION_FAILURE, 387
EXECUTION_SUCCESS, 387
exglob extended pattern-matching operators, 515
exit, 70, 350
exit 0, 84
exit code, 363
exit status ($?), 74, 354
expand_aliases, 370
export command, 357
exported environment variables, 468
exported value, changing, 88
exported variables, 87, 467
expressions, short-circuited, 117
ext script, 57
external commands, 13
extglob option (extended pattern matching), 122
F[ Top ]
-f option (awk) counting string values, 160
-F option (awk) to delineate fields, 155
-F option (ls), shows type of file with trailing designators, 9
-F switch (tail), 39
-f switch (tail), 39
FC (see Fedora Core)
feature creep, 230
Fedora Core
'ps' command, 170
bash login rc files, 396
customize the $PS1 and $PS2 variables, 353
Red Hat distributions, 19
fg command, reconnects to a background job, 73
field delimiter, 272
field separator, 168, 254, 272
fields, 170, 264, 266
FIELDWIDTHS, 273
FILE1 -ef FILE2, for locating identical files, 116
FILE1 -nt FILE2, checks modification date, 116
FILE1 -ot FILE2 , for locating "is older than dates", 116
filenames
$( ) dollar sign, parentheses, for filenames on command lines, 147
${ } argument, 105
'{}', holds names during command execution, 193
.jpg, 121
= (equal) symbols in, 81
delimit substitutions, 105
delimit the reference, 105
file characteristics, testing, 114
filename expansion, 10
finding, 186
for loop, 105
ls, shows names of, 9
mv command, 105
odd characters in, 186
operators, string-manipulation, 106
and quotes, 93
random, for security, 293
renaming, 105, 411
searches, 147
slash (/), 105
use of meaningful ones, 294
files
$( ) dollar sign, parentheses, for filenames on command lines, 147
.[!.]*, for filename expansion patterns, 11
.0, for formatted manual pages, 27
.html, for HTML versions, 27
.ps, for postscript versions, 27
/etc/passwd file, 16
= (equals) symbols, in filenames, 81
AND (-a), 117
batch job, logging, 418
characteristic, testing for more than one, 117
compression, 172
converting to CSV, 277
counting differences of, 426
CSV data file, parsing, 278
data files, compare and find lines in, 436
deleting using an empty variable, 474
descriptor, 38
editing in place, 432
expression, short-circuited, 117
extensions, 174
extensions, uncompressing, 174
file characteristics, testing, 114
file command, 175
file handles, 335
FILESIZE function, 240
finding by content, 192
finding by date, 189
finding by size, 192
finding by type, 191
finding content quickly, 194
finding existing files quickly, 194
finding with list of locations, 195
for information on specific files, 8
files (continued)
index for several, 422
info, 413
info command, 413
info program, 413
line breaks, eliminate, 275
ls -l, provides file details, 9
ls options, 9
metadata recovery, 421
-mtime predicate to find, 190
naming, 173
operations, speeding up resulting, 187
OR (-o), 117
overwrite, 172
permissions, 69
quotes, around file arguments, 411
Red Hat, util-linux package, 413
rename commands, 413
rename from_string to_string file_name, 413
renaming, 411
sessions, logging, 418
-size predicate to find, 192
symbolic links, 188
system-level, 287
tar command, 172
temporary files, and security, 282, 292
test options, 116
testing, 117
Texinfo, 413
Unix permissions, 300
unzipping, 246
updating specific fields, 266
ZIP, 246, 414
find command
find utility, 185
finding by file content, 192
finding by file date, 189
finding by file size, 192
finding by file type, 191
finding existing files quickly, 194
finding file by content quickly, 194
finding files with list of locations, 195
finding IP addresses, 335-338
listing files, 145
Metadata, capturing for recovery, 421
MP3 files, locating, 239
phrases, searching for, 163
printf formats, 421
xargs command, 343
fingerprints, 315
Firefox 1.0.7, 326
fixed-length data (fixed-width), 273
fixed-width data, 273
flags, 163, 249
floating-point values, 131
fmt command, 181
-follow predicate to find, 188
FollowMeIP, 337
for loop, 67, 85, 91, 130, 157, 327, 343, 449
for syntax, for looping with a count, 130
forced commands, SSH, 316
Fox, Brian, 1
FreeBSD, 20, 183, 197
FREESPACE function, 239
frequently asked questions
.FAQ, 26
awk program, 155
bash default shell, 17
bash official documentation, 25
BSD syslog protocol, 335
chmod command, 53
counting string value, 161
current directory to the $PATH, avoiding, 292
data as histograms, 162
data, discarding portions of, 155
DOS pause command, 450
editing a file in place, 432
file permissions, 53
finding bash for #!, 322
free shell accounts, 25
hidden (.) dot files, 12
interpreter spoofing attacks, 283
IP addresses, finding, 340
noclobber option, 53
pipelines and subshells, 473
prepend data to a file, 429
removing or renaming files named with special characters, 428
reversing word order, 158
RFC 3164, 335
spoofing attacks, avoiding, 283
summing a list of numbers, 159
testing scripts, 325
text paragraphs after a found phrase, 164
Unix shell differences, 27
writing sequences, 448
xargs, "argument list too long" errors, 343
Friebel, Wolfgang, 183
Friedman, Noah, 297
function
arguments, 369
avoiding, 213
call, 256
definitions, 204
function-name, 385
parameters, 205
values, 205
G[ Top ]
gawk, 216
getconf ARG_MAX command, 344
getconf utility, 284, 323
getdate, 220
getline command, 159
getopts, 134, 249, 249-252
globbing (extended pattern matching), 10, 122
Gnome 2.12.1, 326
gnome-apt, 19
GNU
/etc/inputrc, for global Readline configuration, 395
~/.inputrc, 396
date command, 216, 219, 221, 224
find, 344, 421
grep, 437
Linux, 324
long options, 325
Readline customizations, 396
Readline library, 373
run_screen, sample of, 408
screen, installation, 415
sed utility, 429
seq utility, 449
tar utility, 173
Texinfo, 413
Text Utils, 23
xargs, 344
Google Desktop Search, 194
GOTO, 348
greater than sign (>) redirect output, 48
greater than, equal sign (<=), 240
grep, 254, 262
awk, outputting to, 159
-c option, 427
-c, created fewer lines to search for, 427
complex pattern searches, 152
compressed files, 154
egrep, 265, 363
ext script, for parameterization, 57
filename output, 262
find command, 383, 421
grep '<a', 254
grep command, 56
grep -l PATH ~/.[^.]*, 361
grep -o, 265
grep -v, 151
gzcat, 154
-h switch, 146
-i option, 149
-i option, (grep), makes search case-insensitive, 57
-l option, 147
output, 442
pipelines, 150
ps command, 442
-q (quiet) option, 148
regular expression, 152
single quote ('), 254
supply with a source of input, 146
text-related utilities, 144
variables, to find specific, 90
vary output with options, 146
zgrep, 154
groff -Tascii, 27
Groupe Bull, 22
gsub, 272
guest users, restricting, 301
GUI, 19
GUI Rpmdrake, 19
gunzip utility, 391
gzip, file compression, 172
H[ Top ]
-h for getting help, 6, 14
-H option (grep), 193
-h switch (grep), 146
hangup (hup) signal, 76
hash -r command, 286
hash, one-way, 307
hashes, 159, 307
head commands, 39
header lines, 40
hello.c, 384
help_array, 385
help command, 6, 14
here-document, 56
<<- for indenting, 59
<< syntax, 56
data kept with script, 56
HTML in scripts, 236
indenting for readability, 59
odd behavior in, 57
Hex, viewing output, 333
hexdump, 333
hidden (dot) files, 10
histappend, 379
history
!! (double exclamation point) operator, 150
~/.bash_history, for default storage file, 395
CHANGES, to change bash, 26
histogram, 161
history command, 376
history number, 359
setting shell options, 377
sharing, automation of, 377
synchronization between sessions, 376
Host_Alias, 306
host, external, 336
host restriction, 317
.html for versions, 27
HTML, parsing, 253
hunks, sections of changed data, 426
I[ Top ]
-i option (xargs), 187
-i option, (grep), makes search case-insensitive, 57
I/O redirection, 506
IBM, 22
if command, 363
if list, 112
if statement, 71, 74, 75, 100, 111, 240
if test, 97
if/then, to identify options, 248
if/then/else branching, 67
ifconfig, 336
ignoreboth, 378
ignoredups, 378
ignorespace, 378
-iname predicate to find, 189
indenting for readability, 59
index, for several files, 422
info command, 413
info2man, Texinfo viewer and converter, 414
info2www, Texinfo viewer and converter, 414
InfoZip, 78, 285
initialization (rc) files, 394
input
$INPUTRC, for readline, 371
$PASSWD, 65
$REPLY, 64
$THISPACKAGE, 62
/etc/inputrc, for readline, 395
/proc/core, for accessing passwords, 65
<< syntax, for here-documents, 56
<<- syntax, for indenting here-documents, 59
choice function, prompts for and verify a package date, 62
command filename, 55
core dumps, accessing passwords, 65
EOF (end-of-input word), 237
getting input, from other machines, 340
grep command, 56
here-document, indenting for readability, 59
inputrc, sample of, 407
leading characters, 60
-p option (read), 60, 65
password prompt, 65
preprocessors, 182
printf, 65
read statement, 60
redirection, (< less than symbol), 55
REPLY, 60
root, 65
-s option (read), 65
select, 64
SSH certificates, 65
stty sane, to fix echo, 66
stty sane, to restore echo, 66
tab character, 59
user input, 60
validation, 296
whitespace, trailing, 59
yes or no input, 61
.inputrc, 371
inputrc, sample of, 407
INSTALL, bash installation instructions, 26
integer expressions, 108
Internal Field Separator (bash $IFS), 254, 268, 270, 287
internal_getopt, 387
IP address, 167, 335-338
ireset_internal_getopt, 387
ISO 8601, displays dates and times, 218
J[ Top ]
-j, for bzip2, 173
job number, 73
jobs, 76, 354
K[ Top ]
k (kilobytes), 192
KDE-based desktop distribution, 326
Kernighan, Brian, 320
key pair, creation, 309
keychain, 308, 313-315
keyphrase, 163
keyword command, 214
keywords, processing on command line, 532
kill command, 76, 392
kill -l, 207, 211
Knoppix, 19
kpackage, 19
L[ Top ]
-l chpass, changes bash default shell, 16
-l option (grep), 147
-L option (ls), for linked file information, 9
-l option (ls), for long listing, 9
-l option (unzip), to convert Unix end lines, 173
-L, (pwd, cd) displays logical path, 5
last in, first out mechanisms, 454
leading characters, 60
leading dot and slash (./), for accessing current directory, 7
leading dots in filenames, 398
leading, trim, 268-271
leap years, 226, 227
Learning the bash Shell, 25, 301, 384, 389
lefthand side (LHS), 277
less command, 44, 155, 182
less utility, 155
less -V, 447
lesspipe*, 182
lesspipe.sh, 183
let statement, 108
LHS (lefthand side), 277
libraries, third-party, 389
line breaks, eliminate, 275
line counting, 180
lines, numbering, 446
lines, removing duplicates, 171
links, symbolic, 188, 237
Linux
$PATH, changing, 397
/bin/bash, 370
/etc/apt/sources.list, 19
/etc/profile, 363
Add/Remove Applications, 19
application installation, 17
application upgrades, 17
bash versions, 17
CentOS, 19
crontab, 228
Debian, 17
DOS files, convert to Linux, 178
error message, 19
FC (Fedora Core), 19
gnome-apt, 19
GUI Rpmdrake, 19
info, 413
Knoppix, 19
kpackage, 19
Linux API emulation, 23
Linux API functionality, 23
Mandrake, 19
Mandriva, 19
MEPIS, 19
Red Hat, 363
Red Hat Enterprise Linux (RHEL), 19, 197
root, 17
sort comparisons, 169
SUSE, 19, 183
Synaptic, 19
tarball.tar.gz, 172
Ubuntu, 326
Vixie Cron, 228
YaST, 19
Linux Security Cookbook, 308
listing, of all built-ins commands, 14
lithist, 379
Live CDs, 19
-ll option, (unzip), convert DOS end lines to Unix, 173
loadable built-ins, 384
locale setting, when sorting, 168
locate, 7, 194
locating identical files, 116
locating "is older than" dates, 116
log messages, eliminating by error, 151
logger, 335, 345
logging, 418
logmsg, 350
looping, 130
loptend, 387
ls -a, shows all files, 10
ls command, shows filenames, 7
ls -d, 10
ls -l, 9, 156
ls options, 9
ls, shows filenames, 9
lynx, 336
M[ Top ]
m (trailing), indicates color escape sequence, 360
MAC (Mandatory Access Controls), 304
Mac OS X
/bin/sh, 21
10.4, and curl, 336
bash-2.05, 21
bash versions, 21
BSD, 325
chsh, opens editor, 16
cut command, garbles output, 170
Darwin, 21
DarwinPorts, 21
default user shell, 3
Fink, 21
HMUG, 21
Mac OS 10.2 (Jaguar), 21
Mac OS 10.4 (Tiger), 21
source bash, 21
sudo, 435
Macdonald, Ian, 389
macros, for shell interaction documentation, 362
mail, 346
Mail User Agent (MUA), 348
mail*, 347
MAILTO variable, 347
mailx, 346
Makefile, 384
malicious script, /tmp/ls, 292
man command, 6
man in the middle attacks, 315
man sudoers, 306
Mandatory Access Controls (MAC), 304
Mandrake, 19
Mandriva, 19
manpages, 6, 27
manual pages, formatting, 27
Mastering Regular Expressions, 266
M/D/YY formats, avoid, 218
meaningful_prefix, and security, 294
menus, 137
MEPIS, 19
Message Transfer Agent (MTA), 346
metacharacters, 532
Meta Ctrl-V, displays variable for editing, 362
meta key (screen command mode), 416
Microsoft Services for Unix, 24
Midnight Commander, 292
MIME-aware update, to mail, 347
mkdir command, 382
mkdir -p -m 0700 $temp_dir, avoids race condition, 293
mkisofs, 242
mktemp, 293
MM/DD/YY formats, avoid, 218
modification dates, 116
MP3 files
$$ (double dollar sign) variable, 243
<= (greater than, equals sign), 240
== (double equals signs), 240
-A option (mkisofs), 244
available space, tracking when loading, 238
cat program, 244
cdAnnotation, 244
cdrecord, 242
CDs, burning, 242
FILESIZE function, 240
find command, 239
FREESPACE function, 239
if statements, 240
loading, tracking available space automatically, 238
mkisofs, 242
MP3 player, 237, 238
-p option (mkisofs), 244
REDUCE function, 240
-V parameter (mkisofs), 244
while loop, 239
MP3 player, loading, 237
mpack, 347
-mtime predicate to find, 190
MUA (Mail User Agent), 348
multiplication symbol, 143
mysql command, 263
MySQL, databases setup with, 262
N[ Top ]
N log files, 439-442
-n option (sort), for sorting numbers, 166
-name '*.txt', to narrow searches using find, 193
-name predicate to find, 185
NetBSD, 20, 169
Netcat, 334, 345
Net-redirection, 334
network redirection feature, 345
network traffic, 334
new line with echo, -n option, 32
NEWS, changes to versions of bash, 25
NF variable (awk), 156, 160
no command-line tools, 336
No such file or directory error, 463
no_options(list), 386
noclobber option, 52
nohup command, 76, 200
NOPASSWD option, 307
NOT constructs, 190
NOTES, configuration and operation notes, 26
NSA's Security Enhanced Linux (SELinux), 304
NSF, to store test scripts and data, 326
NTP (Network Time Protocol), 216, 226
null, 101, 387
null strings, and shopt -s nullglob option, 344
number of days between two dates, 222
-number switch (head, tail), changes number of lines, 39
numbering line, 446
numbers, 158, 450
numeric data, sorting, 166
O[ Top ]
-o options (recipe 6.4), 243
octal dump command (od), 333
octal modes, 298
od (octal dump command), 333
ODF (Open Document Format), 245, 275
OFS (awk output field separator), 272
one file per line option (ls -1), 9
online references, shell security, 281
Open Document Format (ODF), 245, 275
OpenBSD, 20, 280
OpenSSH, 280, 308, 318
operations, speeding up resulting, 187
operators
!! (double exclamation point) history, 150
*.txt, for pattern matching, 11
:- assignment operator, 101
:+ variable operator, 203
?, shell pattern matching operator, 11, 514
-a operator, 115
assignment, 109
comma operator (,), 110
comparison, 120
double greater than operator (>>), 115
eq operator, 120
-eq operator, for numeric comparisons, 119
extended pattern-matching, 10
Perl, 120
redirection, 38
string-manipulation, 106
option filename, 116
options
and arguments, 249
filename, 116
history options, 377
promptvars shell option, 357
-s option (example loadable builtin), 385
setting on startup, 353
standalone, 249
turn off interactively, 353
OR (-o), 117
OR constructs, 190
Outlook, 347
output
$( ) (dollar sign, parentheses), for command substitution, 46
&> (ampersand, greater than sign), sends STDOUT and STDERR to same file, 38
/dev/null, 41
> (greater than sign) redirect output, 33, 35, 48
>& (greater than sign, ampersand), sends STDOUT and STDERR to same file, 38
>> (double greater than), append the output, 39
| (pipe symbol)
-1 (ls minus one) option, 36
adding prefix or suffix to, 444
bit bucket, 41
braces ({ }), for grouping output, 42
buffered, 49
-C option, (ls), redirects output, 35
clobber a file, 53
control over placement of, 31
display beginning of file, 39
display end of file, 39
divert output, 47
double quotes ("), to preserve spacing, 30
dump unwanted data, 41
output (continued)
echo command, 29
eliminating output, 41
file descriptor, 38
formatting control, 31
function call, 256
grouping from several commands, 41
head commands, 39
header lines, 40
header lines, skipping, 40
less command, 44
line output, keeping selected portions, 156
ls command, 35
messages.out, 37
-n option, new line with echo, 32
newline default, 32
noclobber option, 52
-number switch (head, tail), changes number of lines, 39
OFS (awk field separator), 272
output messages, redirect to different files, 37
overwriting, 52
parentheses ( ), redirects subshell's execution, 42
parsing into an array, 255
partial elimination, 155
pathnames, for redirecting output, 34
piped I/O, 44
plus (+) sign for offsetting top of the file, 40
printf, 31
programs, connecting two, 43, 46
redirect messages, 37, 48, 342
redirection operators, 38
reserved words, 42
rm command, 46
save to other files, 34
saving from a command, 33
single quote ('), to preserve spacing, 30
sorted, 165
split, 332
STDERR (>&2), 38
STDIN (standard in), 49
STDOUT (standard output), 37, 49, 50
tail commands, 39
tee command, 45, 50
unbuffered, 49
using as input, 43
viewing, in Hex, 333
P[ Top ]
-p option (mkisofs), 244
-p option (read), 60, 65
-p option (trap), 210
package dates, verification, 62
paragraphs, rewrapping, 181
parameters
$* (unquoted), 95
$@ (unquoted), 95
${!prefix*}, for programmable completion, 287
${!prefix@}, for expansion, 287
${parameter#[#]word}, 480
${parameter%[%]word}, 480
${parameter/pattern/string}, 480
embedded blanks, 92
errors in, 94
errors using $*, 94
expansion of, 103
function parameters, 205
positional arguments, 101
quotes, around, 93
unsetting of, 103
-V parameter (mkisofs, 244
parentheses ( ), 42, 190
parsing
${#}, for direct parsing, 248
arguments, 231, 248
characters, one at a time, 260
command-line arguments, 134
CSV data file, 278
directory names, 175
HTML, 253
output into an array, 255
output, with a function call, 256
with read into an array, 258
text, with a read statement, 257
passphrase, changing and protection, 308
passwd, changes bash default shell, 16
passwords, 65, 299, 307, 308
patch, 422-425
path, security, 283
PATH="$PATH:newdir", 362
PATH="newdir:$PATH", 362
pathnames
absolute, 176
expansion of, 534
using Tab key to finish the name, 459
paths
absolute, 284
modifying, 366
permanently change, 361
setting explicit, 362
updates, 361
pattern matching
${parameter/pattern/string}, 480
${variable/pattern/replacement}, 195
*.txt, 11
.jpg, 121
?, shell pattern matching operator, 11, 514
asterisk (*), match any number of characters, 121
bash alphabetizes, 470
bash version 3.0, 123
case sensitivity, 122
double bracket compound statement ([ [ ] ]), for matches on righthand side of equals operator, 121
egrep, 363
extglob option, for extended matching, 122
globbing (extended pattern matching), 122
patterns, strings containing an asterisk (*), exclamation sign (!), or bracket ([), 10
question mark (?), for matching a single character, 121
and regular expressions, 152
searches, ignoring case, 149
searching with complex patterns, 152
symbols, grouping, 122
symbols to use for, 480
testing strings with, 121
pattern-matching characters, 514
pause command (DOS), 450
PC-BSD, 326
PCRE (Perl Compatible Regular Expressions), 266
percent sign (%) to format specifications, 31
period (.), 152
period, asterisk (.*), with file wildcards, 10
Perl, 84, 120, 224, 227, 266
Perl Best Practices, 84
Perl Cookbook, 451
Perl's date and time data structure, 223
Permission denied, error message, 462
permission information storage, 7
permissions, 298
personal utilities, 373
phases, 348
phone-number lookups script, 56
photo albums, 233-237
photos, 232, 233
phrases, searching for, 163
PID (process ID, $$), 73, 443
pinfo, Texinfo viewer and converter, 414
piped I/O, 44
pipeline searches, 149
pipelines, subshell creation, 470
pkg_add (bash installation/update), 20
pkg_add -vr, 20
plural function, 260
plural noun, 259
pn_day, 222
pn_day_nr, 222
pn_month, 222
pn_weekday, 222
POD (Plain Old Documentation), 84
pod2* programs, 84
Polar Home, 24
popd built-in commands, 454
POSIX, 168, 211, 284, 321, 322, 368
postscript file versions (.ps), 27
pound (#) character, 82
pr command, 181
Practical UNIX & Internet Security (O'Reilly), 281
predicates, 185
prepend data, 429-432
previous and next x days of the given day, 222
previous and next x days of the given day, non-recursive, 222
previous and next x months, 222
-print condition (find), 185
-print0 (find, xargs -0), 186
printf, 31, 65, 135, 329, 474, 509
private key, 309
problems, portability, 284
processes
automating, 348-351
verify it is running, 443
profile settings, system-wide, 400
programmable completion, 287, 389
prompt string customizations, 483
prompts
# (pound) trailing prompt means root, 4
$ dollar sign, trailing, means logged as a regular user, 4
$PROMPT_COMMAND, 359
$PS1, command prompt, 357
prompts (continued)
$PS2 (secondary prompt string), 374
$PS3, select prompt, 357, 374
$PS4, 376
~ (tilde), default for home directory, 4
0m, clears all attributes and set no color, 360
basic examples of, 353
changing, on simple menus, 138
choice function, 62
customizing, 353
default prompts, 4
directory location, 5
downloads for this book, 356
find and run particular commands, 6
keep short and simple, 359
-L, (pwd, cd) displays logical path, 5
password prompt, 65
printing strings, with -p option (read), 60, 65
promptvars shell option, 357
pwd (print working directory) built-in command, 5
root, 5
secondary, 374
to show everything, 355
strings, 357
su command, 5
sudo command, 5
who did what, when, and where, 355
xtrace, 357
ps, showing passwords on command line, 299
PTY, pseudo-terminal number, 354
public key, 309, 310
pushd built-in commands, 454
pwd (print working directory) built-in command, 5
Q[ Top ]
-q (quiet) option (grep), 148
-Q option (ls), for quote names, 9
question mark (?), 10, 121
quoting
" double quotes, 12
$* (unquoted), 95
$@ (unquoted), 95
$VAR expression, 119
' (single quote), 12, 30, 152, 212
\ (backslash), 12
in arguments, 32
backward quotes (``) (see also $( )), 46
command not found errors, 468
command-line, 12, 535
double quotes ("), to preserve output spacing, 30
filenames, 93
parameters, 93
-Q option (ls), for quote names, 9
quotes, 411, 468
smart quotes, removing, 179
trailing spaces, 12
unquoted text, 12
variable references, 93
R[ Top ]
-r option (ls), for reverse sort order, 9
-R option (ls), to recurse though subdirectories, 9
-r options, 245
r00t, 282
race condition, 282, 293
Ramey, Chet
=~, and use of regular expressions in bash, 480
bash web site, 21, 25
for loops, 344
input validation, 297
Mac OS 10.2 (Jaguar), 21
Mac OS 10.4 (Tiger), 21
using printf with a suitable local, 450
rbash.1, for shell manpage, 26
RC (initialization) files, 394
RC files, creating portable files, 398-400
RE (regular expression), 145, 152, 159
RE (regular expressions), for pattern matching, 122
read statement, 60, 129, 257, 258
readability, indenting for, 59
readline, 201, 362, 371
readline.3, readline manpage, 26
README, bash description, 25
real arguments, 98
reconnect to a background job, 73
recovering sessions, 415
Red Hat, 183, 196, 304, 321, 413
Red Hat Enterprise Linux (RHEL), 19, 197
redirecting operator (>), 200
redirection operators, 38
REDUCE function, 240
regular expressions (RE), confusing with shell wildcards, 480
relative directory, 173
relative pathname, 35
removing directories, 362
rename commands, 413
rename from_string to_string file_name, 413
rename, Perl-based, 413
repetition mechanism, for searches (\{n,m\}), 153
replace, and search globally, 254
REPLY, 60, 268-271
reserved words, 42
RETURN signal, 210
RHS (righthand side), 277
rm command, 46, 74
Robbins, Arnold, 281
Robbins, Daniel, 313, 314
root account, 4, 16, 65, 361
ROT13, 307
ROT47, 308
RPM (Red Hat Package Manager), 22, 173
RPN (postfix) notation, 140
RPN calculator, 139
rsh (Remote Shell), 303
rssh, 318
rsync, 317
run commands from variables, 78
run commands in the background, 72
run several commands at once, 72
run several commands in sequence, 71
run the next program, 72
run_screen, sample of, 408
running scripts, several at one time, 79
S[ Top ]
-s option (example loadable built-in), 385
-S option (ls), to sort by file size, 9
-s option (read), 65
-S, turns off stable sort on NetBSD, set buffer size otherwise (sort), 168
Schneier, Bruce, 280
scp, using without a password, 308
screen command mode (meta key), 416
screen
caveats, 416
for sharing a single bash session, 417
clearing when logging out, 420
script-kiddies, 280
scripts, 203, 419
" (double quotes), 254
# pound, 82
$ (*dollar, asterisk), 91
$* (unquoted), 95
$@ (unquoted), 95
${#}, 96
${#}, for direct parsing, 248
${#VAR}, 97
${:=} operator, 101
${:?} syntax, 103
${:-} syntax, 99
${1:0:1} syntax, tests 1st character of 1st argument, 248
${VAR#alt}, 97
$0 variable, 236
$i variable, don't use (see also $x), 85
$include, 201
$VERBOSE, 98
$x syntax, 85
' (single quote), 254
.bad, 105
/tmp/ls, and malicious, 292
:- assignment operator, 101
:+ variable operator, 203
:= (colon, equals sign), 102
<a> tags, 253
@ (at sign), 203
~/bin directory, collecting in, 373
-a operator, 115
arguments, 91, 96, 104, 231, 248
arithmetic expansion, 103
array, 106, 107, 255
awk script, 175
basename command, 136
bash $IFS (Internal Field Separator), 258
bash functions, 203
behavior, changing, 125
bit placement, 85
braces ({ }), 87, 91
branching construct, 111
breaking a line, 86
browser, viewing photos with, 233
call by value, 88
case statement, 250
case, identify options, 248
cat command, 236
character default, for paper and screen, 85
characters, one at a time, 260
colon (:), 83
command not found error, 204
command substitution, 103
comments, 82
compound commands, 114
configuration files, 200-203
configure script, 388
daemon, 199
data validation, 282
DEBUG signal, 210
scripts (continued)
debugging, 477
default values, 99, 100
delimit substitutions, 105
diff, to compare content of two documents, 246
directory, 232, 291
documentation, 82
documents, comparing, 244
dot (.), 201
double greater than operator (>>), 115
double parentheses ((( ))) construct, 127
ed script, 433
else clause, 111
else-if (elif), 111
EMIT function, 236
end-user documentation, 83
env (export -p), 88
EOF (end-of-input word), 237
error messages, 103, 251
ERROUT function, 236
exit 0, 84
exported value, changing, 88
extglob option (extended pattern matching), 122
feature creep, 230
field separator, 254
file characteristics, testing, 114
file test options, 116
FILE1 -ef FILE2, for locating identical files, 116
FILE1 -nt FILE2, checks modification date, 116
FILE1 -ot FILE2, for locating is "older than dates", 116
flags, 249
for loop, 85, 91, 105
function call, parsing output, 256
function definitions, 204
function parameters, 205
functions, 85
function values, 205
getopts, 134, 249-252
grep, 90, 254
here-document, 83, 236
HTML, parsing, 253
if list, 112
if statement, 100, 111
if test, 97
if/then, to identify options, 248
indentation, 85
keychain, 313
kill -l, 207, 211
line breaks, 85
log messages, eliminating by error, 151
mv command, 105
nohup command, 200
NOPASSWD option, 307
null, 101
ODF (Open Document Format), 245
opening comments, 97
operators, string-manipulation, 106
option arguments, 98
options, standalone, 249
options, with arguments, 249
output, parsing into an array, 255
output, writing across several statements, 32
-p option (trap), 210
parameters, 90, 92, 101, 103
passwords, 307
pattern matching, case sensitivity, 122
Perl, 84
photo albums, 233-237
plural function, 260
plural noun, 259
POD (Plain Old Documentation), 84
print a line of dashes, 230
printf, 135
quotes, around parameters, 93
RE (regular expressions), for pattern matching, 122
read statement, parsing, 257, 258
readability, 85
readline, 201
redirecting operator (>), 200
redirections, 125
RETURN signal, 210
root account, 4
running a series of, 79
running on Nth day, 228
scp, using without a password, 308
search and replace, globally, 254
searches, complex, 152
searches, narrowing, 151
security problems with, 282
semicolon (;), 112
set command, 89
setgid, 300
setuid, 300
shell scripting, 3
shift built-in command, 135
shift statement, 250
signal handlers, 208
signal number, 208
slash (/), 105
sourcing, 201
space characters, 92
square brackets ([ ]), 126
STDERR (>&2), 200
STDIN (standard input), 200
STDOUT (standard output), 200
string constants, using for default, 102
substring function, 260
symbolic links, 237
syntax, verifying correctness of using bash, 476
test command, 113
test -t option, 125
test, avoid naming as, 466
then (if), 112
tilde (~), for expansion, 103
trap interrupts, 207
trap signals, 207
trap utility, 207
trapping, 207-211
tty, 199
unzipping files, 246
USAGE function, 236
-v argument (for verbose), 98, 347
variable errors, 94
variable names, 85, 86
variable reference, use full syntax, 87
variables, 87, 89, 478
while loop, 126, 128
while read, 127
whitespace, 85
word content, document comparison, 245
write only syntax, 82
xtrace, for debugging, 478
zero returns, 127
ZIP files, 246
scripts, writing advanced
#!/bin/sh, avoid using, 321
$result, 341
$SSH_ID, 341
$SSH_USER, 341
/sbin/ifconfig -a, 338
/usr/bin/env command, 321
{ } braces, 341
ARG_MAX, 344
ARG_MAX, limits in bytes, 344
arguments, breaking up, 343
arguments, list too long error, 343
bash portables, finding, 321
bash, built-in network redirection feature, 345
Browser Appliance v1.0.0, 326
BSD, 325
case statement, 349
characters, unprintable, 333
command command, 324
command -p, 324
command substitution, 340
cron, 347
cross-platform scripts, 326
cross-platform scripts, avoid, 324
CS_PATH, 323
curl, 336
echo, 329-331
echo portability, 329
egress filtering, 337
email, sending, 345-348
env command, 321
exec command, 335, 342
exit, 350
file handles, 335
find command, 343
Firefox 1.0.7, 326
FollowMeIP, 337
for loop, 343
for loop portables, 327
getconf ARG_MAX command, 344
getconf utility, 323
Gnome 2.12.1, 326
GNU long options, 325
GOTO, 348
hexdump, 333
host, external, 336
ifconfig, 336
input, getting from other machines, 340
IP address, external and routable, 336
IP addresses finding, 335-338
KDE-based desktop distribution, 326
logger, 345
logger utility, 335
logmsg, 350
lynx, 336
Mac OS X, 325
Mac OS X 10.4, and curl, 336
mail, 346
mail*, 347
mailto, 346
MAILTO variable, 347
mailx, 346
MIME-aware update, to mail, 347
mpack, 347
scripts, writing advanced (continued)
MTA (Message Transfer Agent), 346
MUA (Mail User Agent), 348
Netcat, 334, 345
Net-redirection, 334
network traffic, 334
no command-line tools, 336
NSF, to store test scripts and data, 326
od (octal dump command), 333
Outlook, 347
output, redirect for entire script, 342
output, split, 332
output, viewing in Hex, 333
PC-BSD, 326
phases, 348
POSIX, 321
POSIX $PATH, setting, 322
printf "%b", 329
processes, automating, 348-351
Red Hat, 321
script testing in VMware, 326
shell scripts, portable, 324
shopt -s nullglob option, expands files to a null string, 344
Solaris, 325, 333
split command, 332
SSH, with public keys, 340
syslog messages, 335
syslog priority value, 335
syslog, log to, 345
Thunderbird, 347
Ubuntu Linux 5.10, 326
UDP, 335
uuencode, 346
-v argument (for verbose), 347
virtual machines, prebuilt, 326
virtualization packages, getting free, 326
VMware, 325
VMware player, 326
VMware Server, 326
VNC-based VMware Console, 326
wget, 336
whitespace, 333
writing portable scripts, 320
x86 architecture, 326
xargs command, 343
xpg_echo, 329
sdiff, 437
searches
${variable/pattern/replacement}, 195
$IFS=':', 196
$PATH, 195
\{n,m\}, repetition mechanism, 153
AND constructs, 190
apropos, searches manpage for expressions, 7
Beagle, desktop search engine, 194
-c, created fewer lines to search for (diff), 427
command command, 197
complex, 152
Copernic Desktop Search, 194
desktop search engines, 194
files, 194, 195
finding by file content, 192
finding by file date, 189
finding by file size, 192
finding by file type, 191
-follow predicate to find, 188
for filenames, 147
Google Desktop Search, 194
-i option, (grep), makes search case-insensitive, 57
-iname predicate to find, 189
-l option, with grep, 147
locate, 194
-mtime predicate to find, 190
-name '*.txt', to narrow searches using find, 193
narrowing, 151
NOT constructs, 190
OR constructs, 190
phrases, searching for, 163
pipeline, 149
repetition mechanism for, 153
search and replace, globally, 254
-size predicate to find, 192
slocate, 194
Social Security Number, 153
source command, 195
Spotlight, desktop search engines, 194
true or false, 148
-type d (find directories), 191
type -P, 195
-type predicate to find, 191
-v option (grep), 151
secondary prompt string ($PS2), 374
seconds, 226, 227
secure paths, 283
secure shell programming techniques, 281
security
$IFS (bash Internal Field Separator), 287
$PATH, 283
$RANDOM, 292
$temp_dir, 293
$TMOUT variable, 318
$UMASK variable, 288
*.pub (public key), 309
/tmp/ls, malicious script, 292
\unalias -a command, 285
~/bin, security problems, 374
absolute paths, 284
accessing data, on remote machines, 307
accounts, shared, 302
AIDE, 282
aliases, clearing, 285
aliases, malicious, 285
AppArmor, 304
attacker, non-root, 293
Bourne shell, 303
buffer overflows, 282
canonical portable syntax for bash $IFS, 287
chroot command, 303
chroot Jails, 303
--clean option, flushes cached SSH keys (keychain), 313
command hash, 286
comments, changing, 309
common problems with, 282
core dumps, 287
cron jobs, using without a password, 308
crypt hashes, 307
data validation, 282
debugging, and core dumps, 287
directories, temporary, 282
Emacs and vi, allow shell escapes, 303
filenames, use of meaningful ones, 294
files, temporary, 292
fingerprints, 315
from host restriction, 317
getconf utility, 284
guest users, restricting, 301
hash -r command, 286
Host_Alias, 306
input, validation, 296
key pair, creation, 309
keychain, 308, 313-315
leading backslash, supress alias expansion, 285
MAC (Mandatory Access Controls), 304
man in the middle attacks, 315
man sudoers, 306
meaningful_prefix, 294
mkdir -p -m 0700 $temp_dir, avoids race condition, 293
mktemp, 293
NOPASSWD option, 307
one-way hash, 307
online references, shell security, 281
OpenSSH Restricted Shell, 318
passphrase, 308
passwords, 299, 307
permissions, setting, 298
policy, 304
POSIX, 284
private key, 309
problems, portability, 284
ps, showing passwords on command line, 299
public key, 310
r00t, 282
race condition, 282, 293
and random filenames, 293
rbash, restricting login shells, 302
Red Hat Linux, 304
restricted shell, 302
ROT13, 307
ROT47, 308
rsh (Remote Shell), 303
rssh, 318
rsync, 317
scp, using without a password, 308
secure paths, 283
secure shell programming techniques, 281
SELinux (NSA's Security Enhanced Linux), 304
sessions, inactive, 318
setgid, 300
setuid, 300
setuid root spoofing, 283
shebang line, 283
SSH commands, 308, 316-318
ssh-add command, 312
ssh-agent, 308
ssh-keygen (ssh-keygen2), 309
sudo bash, 305
sudoers, 306
system integrity, securing of, 282
temporary files and, 282
trap, setting, 293
security (continued)
Tripwire, 282
Trojan horse, 282
trojaned utilities, 282
ulimit, 287
umask, secure, 288
Unix, file permissions, 300
Unix groups, 300
unprivileged users, 282
urandom, 293
user, non-root, 305
User_Alias, 306
users, inactive, 318
vi and Emacs, allow shell escapes, 303
visudo, for editing, 306
world-writable directories, 289-291
sed, 277
select prompt ($PS3), 64, 137, 357, 374
SELinux (NSA's Security Enhanced Linux), 304
semantic differences, with parentheses, 42
semicolon (;), 72, 112
separators for numbers, 450
seq command, to generate floating-point values, 131
sequences, writing, 448
sessions, 318, 376, 415, 418
set, 371, 482
set command, 89
set -e, 76
set -o functrace option, 210
set -o posix, 211
setgid, 300
settings subdirectory, 398
setuid, 300
setuid root spoofing, 283
SGI, 22
shebang line, 283
shells
$- syntax, lists current option flags, 15
$IFS (bash Internal Field Separator), 268
.rbash.0 , for restricted manpage, 27
/dev/nul for portable scripts, 148
/etc/bash.bashrc (Debian) global environment file, subshell environment file, 395
/etc/bashrc (Red Hat), bash subshells global environment file, 395
/etc/shells, 20
/etc/shells, list of valid, 16
~/.bash_login, for Bourne login personal profile files, 395
~/.profile, for Bourne logging personal profile files, 395
backslash (\), for expansion of, 12
bash $IFS (bash Internal Field Separator), 254
bash $IFS (Internal Field Separator), 270
bash shell, 16
Bourne shell (sh), 1, 3, 303, 395
built-in commands, to ignore functions and aliases, 213
C Shell (csh), 1
cd command, 382
changing root shell on Unix, 17
chpass -s shell, changes default shell, 16
chsh -l, lists valid, 16
chsh -s /bin/bash, makes bash default, 16
chsh -s, changes default, 16
chsh, changes setting in, 16
Cygwin, 3
Emacs, allow shell escapes, 303
embedding documentation in scripts, 83
enable -n, turns off commands, 14
environment adjustment, 371
expand_aliases, 370
free accounts, 24
functions, 203, 221
history options, setting, 377
history, between sessions and synchronization, 376
Korn shell (ksh), 1
-l option, 16
levels of, 354
Linux default user shell, 3
Mac OS X default user shell, 3
macros, for interaction documentation, 362
online references, for security, 281
OpenBSD, 280
OpenSSH, 280
OpenSSH Restricted Shell, 318
parentheses ( ), redirects subshell's execution, 42
passwd -e, changes bash default, 16
passwd, changes bash default, 16
pipelines, subshell creation, 470
promptvars option, 357
rbash, restricting login, 302
restricted, 302
rsh (Remote Shell), 303
script security, 280
script testing in VMware, 326
scripting (programming), 3
secure shell programming techniques, 281
set, 371, 482
shell.h, 387
shopt, 371
shopt -s command, turns on shell options, 122
standard shell, 1
subshells, 42
Unix shell, 2
usermod -s /usr/bin/bash, changes default, 16
variables, testing for equal, 119
vi and Emacs, allow shell escapes, 303
wildcards, confusing with regular expressions, 480
writing portble scripts, 324
Writing Shell Scripts, documentation for, 27
shift, 231
shift built-in command, 135
shift statement, 250
shopt, 371
shopt -s command, turns on shell options, 122
shopt -s nocasematch, changes case sensitivity, 124
shopt -s nocasematch, for bash versions 3.1+, 133
shopt -s nullglob option, expands files to a null string, 344
short form of help, usage, 386
short-circuited expressions, 117
signal handlers, 208
signal names, 392
signal number, 208
Silverman, Richard, 308, 316
single brackets ([ ]), 10, 153
-size predicate to find, 192
slash (/), 35, 105
slocate, 7, 194
smart quotes, removing, 179
Social Security number searches, 153
Software Porting, 22
Solaris, 325
2.x, 22
7, 22
8, 22
cut command, 170
less, 183
sort comparisons, 169
virtual environments, 325
sort
command, 167
comparisons, 169
IP addresses, 167
numeric data, 166
options, 166
pre-sorting, 167
stable, 168
utility, 165
source code, for bash, 26
source command, 195, 201
source tree, 261
sourcing, scripts, 201
space characters, 92
Spafford, Gene, 281
split command, 332
spoofing, setuid root, 283
Spotlight, desktop search engines, 194
SQL query, 219
square brackets ([ ]), 126
SSH
$SSH_ID, 341
$SSH_USER, 341
certificates, 65
commands, disable, 317
fingerprint support, 315
forced commands, 316
host restriction, 317
how the ssh command works, 318
OpenSSH, 308
OpenSSH Restricted Shell, 318
password, without using a, 308
public keys, 340
rssh, 318
SSH commands, restricting, 316-318
SSH Communications Security, 308
SSH forced commands, 316
ssh -v, to locate problems with, 318
ssh-add command, 312
ssh-agent, 308
ssh-keygen (ssh-keygen2), 309
stacks, 454
startup options, 353
STDERR (>&2), 38, 50, 200, 247
STDIN (standard input), 49, 200
stdio.h, 387
STDOUT (standard output), 37, 49, 50, 200
strftime, 378
strftime format specification, 217
strings
$-, list current shell option flags, 15
${parameter/pattern/string}, 480
strings (continued)
$PS2 (secondary prompt string), 374
* (asterisk), matches file patterns, 10
= (or ==), for string comparisons, 119
? question mark, 10
[ bracket, 10
associative arrays (hashes in awk), 159
asterisk (*), 121
built-in test command, 118
characteristics, testing, 118
characters, parsing, one at a time, 260
completion strings, viewing, 392
constant strings, using for default, 102
double bracket compound statement ([ [ ] ]), 121
embedded spacing, 32
-f option (awk) for counting values, 160
filenames, renaming, 105, 411
find all occurrences, 145
first digits, 31
left-align strings, 31
max specifiers, 31
min specifiers, 31
negative sign on specifier, 31
NF variable, for counting string values (awk), 160
null strings, 344
operators, for string-manipulation, 106
output, variations, 146
-p option (read), for printing a prompt string, 60, 65
pattern matches, 121
question mark (?), match single character, 121
quotes, 32, 119
rename from_string to_string file_name, 413
searches, ignoring case, 149
second digit, 31
shopt -s nullglob option, expands files to a null string, 344
single brackets ([), in, 10
substring function, 260
values, counting, 159
stty sane, to fix or disable echo, 473
stty sane, to restore echo, 66
su command, 5, 435
sub-expressions, to populate array variables, 123
subsets, data, 170
subshells, 42
substitutions, across boundaries, 457
substring function, 260
Subversion, 128, 261, 538
sudo, 5, 17, 435
sudo bash, 305
sudo security, 305
sudoers, 306
Sunfreeware, 22
SUSE, 19
svn command, 128
svn status command, 261
symbolic links, 188, 237, 370
Synaptic, 19
syntactic differences, with parentheses, 42
syntax, canonical portable for bash $IFS, 287
syntax, verifying correctness of using bash, 476
syslog, 335, 345
system integrity, securing of, 282
system-wide environment settings, 401
system-wide profile settings, 400
T[ Top ]
-t option (sort), 168
tab character, 59, 170, 271
Tab key, 460
table of contents, view with tar -t, 175
tail commands, 39
tar archives, checking unique directories, 175
tar command, 172
tar -t, view table of contents, 175
tarball, 172, 297
tee command, 45, 50
temporary file security, 282
terminal window, viewing gibberish, 473
test command, 113
test operators, 505
test -t option, 125
Texinfo, 413, 414
text-related utilities
!! (double exclamation point) history operator, 150
$ (dollar sign), 153
$( ) dollar sign, parentheses, for filenames on command lines, 147
$LESS variable, 182
$LESSCLOSE, 182
$LESSOPEN, 182
' single quote, for searches, 152
. period (in regular expressions), 152
.deb files, 173
/dev/nul (for portable shell scripts), 148
[ ] single brackets, 153
\ (backslash), in searches, 152
\{n,m\}, repetition mechanism, 153
^ (caret), matches beginning of line, 153
^total, 159
absolute pathnames, 176
ar archives, 173
associative arrays (hashes in awk), 159
asterisk (*), 152
awk program, 144, 157
awk utility, 155
backslash (\), matches special characters, 153
BEGIN keyword (awk), 158
bit buckets, 148
bzip2, file compression, 172
-c option (grep), 146
case sensitivity, eliminating, 177
case-insensitive search, 149
character translation, 176
compressed files, grepping, 154
compression algorithms, 173
continue statement, 163
CPIO files, 173
cut command, 170
-d option (cut), specify delimiters, 178
-d option (tr), delete characters, 178
-d option, specify delimiters, 170
data subsets, 170
delimiters, 170
directories, and tar archives, 175
directory names, parsing off, 175
DOS carriage returns (\r), deletion, 178
DOS files, convert to Linux, 178
duplicate lines, removing, 171
END keyword (awk), 158
escape sequences, 179
extensions, uncompressing, 174
-f option (awk) counting string values, 160
-F option (awk), to delineate fields, 155
field separator, 168
fields, 170
file command, 175
file compression, 172
file extensions, 174
files, naming, 173
files, overwriting, 172
flags, turning off, 163
fmt command, 181
for loop, 157
getline command, 159
GNU tar, 173
grep compressed files, 154
grep program, 144
gzcat, 154
gzip, file compression, 172
-h switch (grep), to grep, 146
histogram, 161
input preprocessors, 182
input source, with grep, 146
IP addresses, sorting, 167
-j, for bzip2, 173
keyphrase, 163
-l option (unzip), to convert Unix end lines, 173
-l option, with grep, 147
less manpage, 182
less pager, 182
less utility, 155
lesspipe*, 182
lesspipe.sh, 183
line output, keeping selected portions, 156
-ll option, (unzip) convert end lines to Unix, 173
locale setting, when sorting, 168
log messages, eliminating by error, 151
ls -l command, keeping selected portions of line output, 156
-n option (sort), for sorting numbers, 166
NetBSD, stable sorts, 168
NF variable (awk), 156, 160
numbers, summing a list, 158
numeric data, sorting, 166
options (with grep), 146
output, partial elimination, 155
output, variations, 146
paragraphs, rewrapping, 181
phrases, searching for, 163
pipeline searches, 149
POSIX, 168
pr command, 181
pre-sort, 167
-q (quiet) option (grep), 148
RE (regular expression), 152, 159
relative directory, 173
repetition mechanism, for searches, 153
return value of 0, 148
RPM (Red Hat Package Manager), 173
-S, turns off stable sort on NetBSD, set buffer size otherwise (sort), 168
searches, 149, 151, 152, 153
text-related utilities (continued)
sed program, 144
smart quotes, removing, 179
sort comparisons, 169
sort options, 166
sort utility, 165
stable sort, 168
string values, counting, 159
-t option (sort), 168
tab character, 170
tar command, 172
tar -t, view table of contents, 175
tarball, 172
tarball.tar.gz, 172
tarball.tar.Z, 172
textutils, 275
tr command, character translation, 176
tr utility, 179
true or false searches, 148
-u option (sort), to remove duplicates when sorting, 167
uniq, viewing duplicate lines, 171
-v option (grep), for searches, 151
wc (word count) command, 180
words, reversing order of, 157
write only expressions, 153
-Z, for compress using GNU tar, 173
-z, for gzip using tar, 173
zcat, 154
zgrep, 154
then (if), 112
third-party libraries, 389
this week, caution using, 221
thousands-place separator, 450
Thunderbird, 347
tilde (~), 4, 103
time zones, 218, 226
tkman, Texinfo viewer and converter, 414
tokens, processing on command line, 532
tomorrow's date, getting with Perl, 224
tr command, character translation, 176
tr escape sequences, 515
tr utility, 179
trailing m, indicates color escape sequence, 360
translation of characters, 176
trap interrupts, 207
trap utility, 207
trapping, 207-211, 293
tree, filesystem hierarchy, 35
Tripwire, 282
Trojan horse, 282
trojaned utilities, 282
Tru64 Unix, 22
true or false searches, 148
tty, 199
tty built-in, 385
ttyname, 387
turn off built-in commands, 14
txt versions (ASCII text), 27
type command, 13, 213
-type d (find directories), 191
type -P, 195
-type predicate to find, 191
U[ Top ]
u option (sort), to remove duplicates when sorting, 167
Ubuntu
6.10, bash login rc files, 396
cut command, 170
Debian-derived systems, 19
lesspipe, 183
Linux 5.10, 326
sudo, 435
using dash, 21, 321, 324, 329, 368, 400
UCLA, 22
UDP, 335
ulimit, 287
umask, secure, 288
unalias, 369
uncompressing compressed archives, 391
uncompressing files, 174
uniq, viewing duplicate lines, 171
Unix
$PATH, changing, 397
bash versions, 22
BSD Unixes, 17
date command, 216
dates and times, commands omit the year, 226
file permissions, 300
groups, 300
-l option, to convert end lines to DOS, 173
-ll option, (unzip) convert DOS end lines to, 173
Microsoft Services, 24
root shells, changing, 17
shell, 1
tarball.tar.gz, 172
tarball.tar.Z, 172
UnixReview, 221
unprivileged users, 282
unzip files, 246, 414
updates, to paths, 361
urandom, 293
USAGE function, 236
usage message, 203
usage, short form of help, 386
user
documentation, 83
inactive, 318
non-root, 305
unprivileged, 282
usermod -s /usr/bin/bash, changes default shell, 16
user directories, 362
user input, 60
utilities, personal, 373
uuencode, 346
V[ Top ]
-v argument (for verbose), 98, 347
-v option, for searches, 151
-V parameter (mkisofs), 244
values, counting, 159
variables
$ (dollar sign), 81
$* (errors using), 94
$* (unquoted), 95
$@, 94
$@ (unquoted), 95
$0 variable, 236
$HIST* variables, 377
$HISTFILE, 378
$HISTFILESIZE variable, 378
$HISTTIMEFORMAT, 378
$LESSCLOSE, 182
$LESSOPEN, 182
$PS1, 353, 357, 410
$PS2, 353
$PS3, 64, 137, 357, 374
$PS4, 357, 376
= (equals) symbols, in commands, 81
array variable, 106, 123
arrays, 255
braces ({ }), 87
call by value, 88
commands, distinguish between variables and, 81
env (export -p), 88
-eq operator, for numeric comparisons, 119
errors in, 94
exported value, changing, 88
exporting, 87
grep command, 90
MAILTO, 347
name=value syntax, 80
names, 78, 80, 86
reference, use full syntax, 87
running commands from, 78
R-value syntax, 81
set command, 89
spell out names of, 85
syntax, 80
testing for equal shells, 119
values, viewing of, 89
vi, 447
vi and Emacs, allow shell escapes, 303
vi control mode commands, 520
viewers, for documents, 414
viewing completion strings, 392
viewing photos, with a browser, 233
viewing, output in Hex, 333
view command, to verify password file consistency, 16
virtual machines, prebuilt, 326
virtualization packages, getting free, 326
visudo, for editing, 306
VMware, 325
VMware player, 326
VNC-based VMware Console, 326
W[ Top ]
Wall, Larry, 413
Wang, Michael, 446, 451
wc (word count) command, 180
wdiff, 426
wget, 336
which command, 6, 13
which utility, 196
while loop, 75, 126, 128, 239
while read, 127
whitespace, 59, 268-271, 333
wildcards, 10, 480
Windows
bash, 23
Cygwin, 23
GNU Text Utils, 23
Linux-like environment, 23
word content, document comparison, 245
word counting, 180
WORD_LIST, 386
words, reversing order of, 157
world-writable directories, 289-291, 361
write only expressions, 124, 153
X[ Top ]
x86 architecture, 326
xargs command, 186, 343
xpg_echo, 329
xterm, 355, 359
xtrace, 357, 478
Y[ Top ]
YaST, 19
yes or no input, 61
yesterday's date, getting with Perl, 224
Z[ Top ]
-Z, for compress using GNU tar, 173
-z, for gzip using tar, 173
zcat, 154
zero returns, 127
zeroth, 123, 206
zgrep, 154
ZIP files, 246, 414
Return to bash Cookbook