Sams Teach Yourself Shell Programming in 24 Hours
(Publisher: Macmillan Computer Publishing)
Author(s): Sriranga Veeraraghavan
ISBN: 0672314819
Publication Date: 01/01/99
Index
Symbols
- > (redirection sign), eval command, 286
- < sign, quoting, 132
- << operator, here documents, 201
- ; (semicolon), 12-13, 130
- awk command, 261
- ;; command, case statement, 156
- [] (brackets)
- metacharacter, 245
- test command shorthand, 147
- wildcard, globbing, 121
- [0-9]* expression, 298
- \ (backslash)
- echo command escape sequences, 137-138
- newline character, 135
- quoting, 130-131
- tr command, 231
- \n option
- echo command, 138
- ^ character, 246
- metacharacter, 247
- ^M (carriage return), removing from files, 403
- ` (backquote), command substitution, 125
- {} (braces), while statement, 277
- | (pipe character)
- tar files, 359
- tr command, 232
- || operator, 153
- or compound operator, 264
- ! operator, 153
- find command, negating options, 295
- until loop, 164
- !! operator, 408
- != operator, test command, 151
- (double quote), quoting, 132-134
- # character, comments, 30
- #!, 394
- #!/bin/sh, 394
- $ (dollar sign)
- parameter substitution, 415-416
- field operator, 261
- metacharacter, 247
- newline character, 135
- prompt, 10, 14-15
- quoting with double quotes, 133
- variable values, 107
- $! variable, 176
- $# variable, 181
- $$ variable, 176
- $* variable, 176
- compared to $@, 182
- $0 variable, 176-177, 394
- usage statements, 177-178
- $? variable, 176, 396
- $@ variable, 176
- compared to $*, 182
- $USAGE variable, 180
- % (percent sign)
- job number prefixes, 91
- prompt, 15
- & operator
- background processes, 87
- global substitutions, 254
- && operator, 153
- and compound operator, 264
- (single quote)
- awk and sed commands, 242
- filtering, 237
- quoting, 131-132
- * (asterisk)
- metacharacter, 245
- expr command, 298
- wildcard
- basename command, 180
- globbing, 118-119
- + character, shell tracing, 325
- character, getopts command, 183
- -a option, cpio command, 293
- -atime option, find command, 293
- -c option, uniq command, 234
- -ctime option, find command, 293
- -e option
- echo command, 137
- ps command, 96
- -exec action, find command, 295
- -f option, tail command, 226
- -i option
- grep command, 227
- regp command, 228
- -k option, sort command, 236
- -l option, grep command, 230
- m option, uname command, 384
- -mtime option, find command, 293
- n option, 320
- find command, 291-292
- grep command, 229
- sort command, 235-236
- -print action, find command, 295
- -r option
- sort command, 235-236
- uname command, 384
- -s option, tr command, 232
- -size option, find command, 294
- -type option, find command, 292
- -u option, sort command, 233
- v option, 323
- grep command, 228
- x option, 324
- . (period), 408
- . command
- calling functions, 335
- including functions and variable definitions in other files, 397
- hidden files, 39
- metacharacter, 245
- .. (pathname leaders), 55
- / (forward slash), 53
- regular expressions, 243
- sed command, 253
- : (colon), 408
- getopts command, 184
- no-op command, 124
- shell command, 287-288
- ? wildcard, globbing, 120
A
- absolute pathnames, 52
- find command, 290
- abstraction, portability, 389-391
- accounts, 15
- actions, find command, 295
- addperson script, 369-370
- address book, 365
- adding people, 368-372
- deleting people, 372-376
- interactive mode, 368
- listing people in, 366-367
- noninteractive mode, 369
- ALARM signals, 313-314
- example timer script, 315-316
- handler function, 314
- setting timer, 314-315
- unsetting timer, 315
- AlarmHandler function, 314
- aliases, 408
- displaying pathnames for, 288
- ampersand (&)
- background processes, 87
- global substitutions, 254
- anchoring patterns, 247-248
- and-and operator (&&), 265
- appending output to files, 199
- arguments, 178
- basename command, 179
- commands, 11
- considering one at a time, 397
- debugging scripts, 318
- example, 179
- forwarding to another command, 398
- passing to commands with xargs command, 296
- promptRESPONSE function, 343
- shell tracing, 327
- troubleshooting, 180-182
- arithmetic
- bc command, 299
- expr command, 297
- expressions, 412-413
- substitution, 126
- arrays
- accessing values, 110-111
- indices, 109
- notation, 109
- support arrays, 414
- variables, 106-110
- ASCII characters, filenames, 53
- assigning variables, awk command, 267
- assignment operators, numeric expressions, 270
- associating files, with file descriptors, 204-205
- asterisk (*), expr command, 298
- awk command, 242-244, 259-261
- anchoring patterns, 247-248
- built-in variables, 272
- comparison operators, 263-264
- compound expressions, 264
- next command, 265-266
- escaping metacharacters, 248-249
- field editing, 261-262
- flow control
- do statement, 278
- for statement, 278-279
- if statement, 275-277
- while statement, 277
- formatting address book with, 366
- FS, 274
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- numeric variables, 268
- pattern-specific actions, 262-263
- sets of characters, 245-246
- STDIN as input, 266-267
- variables, 267-268
- numeric expressions, 268-275
B
- background processes, 87-89
- fg command, 92
- input, requiring, 89
- moving foreground processes to, 90-92
- output, writing, 90
- preventing termination, 92
- waiting for, 93
- backquote (`), command substitution, 125
- backslash (\), 130-131
- echo command escape sequences, 137-138
- escaping, 249
- newline character, 135
- tr command, 231
- basename command, 179, 400
- Bash shell, 19
- exporting variables, 114
- integer expressions, 412-413
- support arrays, 414
- until loop, 164
- wildcards, 416
- bc command, 299-300
- beeps, sounding a series with sleep command, 289
- BEGIN pattern, numeric expressions, 271-272
- bg command, 91, 408
- binaries, replacing with functions, 212
- bit bucket 395
- block special files, 73
- Bourne shell (sh), 15
- : character, 287
- initialization process, 26
- job control availibility, 397
- parameter substitution, 415-416
- variables, 108
- wildcards, 416
- bash, 15
- Bourne, Stephen R., 16
- braces {}, while statement, 277
- brackets [] metacharacters, 245
- branching directories, 52
- break command, 169-170, 408
- nested loops, 170
- BSD UNIX
- abstraction, getPID function, 390-391
- versus System V, 382-383
- built-in shell commands, 285
- built-in variables, 272-274
C
- C shell (csh), 15-17
- : character, 287
- prompts, 15
- stack 217
- starting from Korn Shell, 99
- tcsh, 15
- caret (^), 246
- carriage returns, removing from files, 403
- case statement, 156, 408
- patterns, 157
- case-sensitive, 53
- cat command, 41-42
- cd command, 56-57, 408
- CDPATH variable, 415
- character special files, 73
- characters, quoting, 131
- chgrp command, 81
- child processes, 98-100
- chmod command, 77
- common errors, 81
- octal method, 80
- symbolic expression, 78-80
- chown command, 81-82
- command interpreters. See shells
- command line
- options, 178
- reprocessing with eval command, 286
- command substitution, 125-126
- single quotes, 132
- commands, 10, 24
- !!, 408
- . (period), 408
- calling functions, 335
- : character, 287-288, 408
- ;;, 156
- accessing by shell, #!/bin/sh 394
- aliases, 408
- arguments, 11
- forwarding to another command, 398
- passing with xargs command, 296
- awk, 242-244, 259-261
- anchoring patterns, 247-248
- comparison operators, 263-266
- escaping metacharacters, 248-249
- field editing, 261-262
- flow control, 275-279
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- pattern-specific actions, 262-263
- sets of characters, 245-246
- STDIN as input, 266-267
- variables, 267-275
- basename, 179
- basename, 400
- bc, 299-300
- bg, 91, 408
- break, 169-170, 408
- nested loops, 170-171
- case statement, 408
- cat, 41-42
- cd, 56-57, 408
- checking success, 396
- chmod, 77
- common errors, 81
- octal method, 80
- symbolic expression, 78-80
- chown, 81-82
- complex, 11-12
- compound, 12-13
- continue statement, 408
- cp, 45
- -i option, 46
- common errors, 45, 63
- directories, 62-63
- interactive mode, 46
- limitations, 358
- multiple inputs, 46-47
- date, 10
- default behavior, 12
- determining if shell can find, 396
- dirname 400
- do statement, 408
- done statement, 408
- echo, 408, 418
- conditional execution, 388
- modifying with backslash, 130
- modifying with single quote, 131
- output, 190-191
- esac statement, 408
- eval, 286, 408
- exec, 100, 408
- exit n, 408
- export, 113, 409
- expr, 297-299
- false, 409
- fc, 409
- fg, 92, 409
- fi statement, 409
- file, 71
- file descriptors, 204
- file tests, 411
- find, 289-290
- -atime option, 293
- -ctime option, 293
- -exec action, 295
- -mtime option, 293
- -n option, 291-292
- -print action, 295
- -size option, 294
- -type option, 292
- combining options, 294
- negating options, 295
- starting directory, 290-291
- find, 400
- for statement, 409
- function statement, 409
- getopts, 409
- globbing, 118
- grep, 226, 418
- line numbers, 229
- listing filenames, 230
- searching for words, 227-228
- head, 224-225
- history, 409
- hostname, 385
- if statement, 144-145, 409
- common errors, 145-147
- integer statement, 409
- integers tests, 412
- jobs, 94, 409
- kill, 97, 409
- -l option, 306
- signals, 307
- let, 409
- ln, -s option, 72
- ls, 38-39
- -a option, 39
- -d option, 70
- -F option, 38
- -l option, 39, 70
- character special files, 73
- directories, 59
- file types, 70
- files, 60
- man, 31-33
- mkdir, 61-62
- mv, 47, 63
- common errors, 64-65
- interactive mode, 47
- renaming files, 401
- newgrp, 409
- no-op (:), 124
- nohup, 92
- option grouping, 40
- options, 178
- output. See output
- passwd, SUID bit, 77
- pausing with sleep command, 288
- print, 409
- with awk, 261
- printf, 341, 419
- output, 194-198
- prompts, 10
- ps, 94-96
- pwd, 55, 409
- quoting
- combining, 134
- echo escape sequences, 137-138
- embedding spaces, 134-135
- filenames with special characters, 136
- newline character, 135-136
- wildcards, 137
- word boundaries, 134
- r, 409
- read, 202, 410
- read, 341
- readonly, 111, 410
- redirecting to /dev/null, 395
- remote shell (remsh, rsh, rcmd, remote), 300-301
- return, 410
- rm, 48, 65, 67
- rmdir, 66-67
- rsh, 387
- running, 10
- sed, 242-244, 250
- anchoring patterns, 247-248
- deleting lines, 251-252
- escaping metacharacters, 248-249
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- multiple sed commands, 255
- pipelines, 255-256
- printing lines, 250-251
- sets of characters, 245-246
- substitutions, 252-254
- select, 410
- separators, 13
- set, 319-320, 410
- shift, 185, 410
- simple, 11
- sleep, 288-289
- sort, 233, 419
- sorting numbers, 235-236
- string tests, 411
- stty, addperson script, 371
- tail, 225-226
- tar, 358
- test, 147, 410
- compound expressions, 153-156
- file tests, 148
- numerical comparisons, 151-152
- string comparisons, 149-151
- tr, 231-232
- character classes, 236-238
- removing carriage returns, 403
- removing spaces, 232-233
- trap, 309, 410
- cleaning up temporary files, 310-312
- type, 288, 410
- typeset, 410
- ulimit, 410
- umask, 410
- unalias, 410
- uname, 383-384
- determining versions with a function, 385-386
- hardware type, 384-385
- uniq, 233
- unset, 112, 410
- until, 410
- wait, 93, 410
- wc, 42-43
- -c option, 44
- -l option, 43
- -w option, 44
- grouping options, 44
- whence, 410
- while, 410
- while loops, 160
- who, 11
- xargs, 296-297
- comments, 30
- common errors, chmod command, 81
- comparisons operators, awk command, 263-264
- compound expressions, 264
- next command, 265-266
- complex commands, 11-12
- compound expressions, 12-13
- comparison operators, 264
- test command, 153-156
- conditional executions, 153, 411. See also flow control
- portability, 387-388
- conditional statements. See flow control
- continue command, 171, 408
- control flow. See flow control
- copying files, 45
- common errors, 45
- interactive mode, 46
- multiple inputs, 46-47
- to different directories, 46
- counter variables, for statement, 279
- cp command, 45
- -i option, 46
- common errors, 45
- directories, 62
- common errors, 63
- multiple, 63
- interactive mode, 46
- limitations, 358
- multiple inputs, 46-47
- cpio command
- -a option, 293
- quoting wildcards, 138
- cross-platform initialization scripts, PATH variable, 214
- csh. See C shell
- customizing paths, with functions, 214-216
D
- date command, 10
- debug mode, variable substitution, 125
- debugging
- debugging mode, 318-319
- invocation activated, 318
- enabling, 318
- execution tracing mode, 324
- function libraries 334
- set command, 319-320
- shell tracing, 324-325
- debugging hooks, 329-331
- logical bugs, 328-329
- syntax bugs, 325-327
- syntax, 320-322
- verbose mode, 322-324
- default actions (signals), 307
- default behavior, commands, 12
- defining variables, 105
- deleting
- lines with sed command, 251-252
- persons from address book, 372
- delimiters, deleting from input file, 231
- delivering signals, 307
- delperson script, 373-374
- descriptors. See file descriptors
- dev directory, device files, 73
- device drivers, block special files, 73
- device files, 73
- DIR STACK variable, 217
- directories
- BSD and System V equivalents, 382
- cd command, 56-57
- changing, 56-57
- cleaning up files, 401
- copying, 62-63
- copying entire trees to remote systems, 301
- creating, 61-62
- determining full pathname, 399
- disk space, 346
- disk space, checking, 344
- find command, -type option, 292
- greping every file in, 400
- home, 56
- info on (ls -ld command), 70
- listing, 59
- listing files in, 38
- moving, 63
- common erros, 64-65
- examples, 364-365
- mvdir.sh, 360-364
- tar files, 358-359
- parent, 52
- pathnames, 53
- permissions, 76
- changing, 77-81
- removing, 65-66
- common errors, 66-67
- rm -r, 67
- subdirectories, 52
- testing for existence, 148
- directory stack
- adding directories to, 217
- adding directories to, 219
- listing, 217
- manipulating (popd function), 219-220
- storing, 217
- directory tree, 52
- filenames, 52-53
- pathnames, 54
- absolute, 54
- relative, 55-56
- dirname command, 400
- dirs function, 217
- disk space
- file ownership, 82
- find command, 295
- function libraries, 344-347
- removing temporary files, 401
- displaying messages, function libraries, 337-339
- division operation (/), expr command, 298
- do statement, 160, 408
- awk command, flow control, 278
- documents
- here, << operator, 201-202
- organizing in directories, 52
- dollar sign ($)
- field operator, 261
- metacharacter, 247
- newline character, 135
- prompt, 10, 14-15
- quoting with double quotes, 133
- variables, accessing values, 107
- done statement, 408
- double quotes (), 132-134
E
- echo command, 408, 418
- -e option, 137
- \n option, 138
- conditional execution, 388
- function libraries, 338
- modifying with backslash, 130
- modifying with double quotes, 132
- modifying with single quote, 131
- output, 190-191
- formatting, 192-194
- punctuation marks, 191
- variable substitution, 191
- passing arguments to, 297
- echo_prompt function, 388
- elif statement, with else statements, 144
- else if statements, 276
- else statement, with elif statement, 144
- embedding in output
- formatting, 192-194
- printf command, 195-198
- punctuation marks, 191
- variable substitution, 191
- END pattern, numeric expressions, 271-272
- environment variables, 112
- exporting, 113
- error messages
- background processes, 89
- output, 190
- redirecting, 205-207
- error messages 338
- errors. See also troubleshooting
- cd command, 57
- cp command, 45
- copying directories, 63
- if statement, 145-147
- ln command, symbolic links, 72-73
- ls command, 60
- mkdir command, 62
- mv command, 64-65
- rmdir command, 66-67
- variable substitution, 124
- esac statement, 408
- escape characters, formatting output with, 193-194
- echo command, 192
- escape sequences
- echo command, 137-138
- metacharacters, 248-249
- special characters, 130
- etc/shadow file, 76
- eval command, 286, 408
- exclamation (!), find command, negating options, 295
- exec command, 100, 408
- exec system call, 394
- execution tracing mode, 324
- exit command, 408
- export command, 113, 409
- exporting, environment variables, 113
- expr command, 297-299
- expressions
- arithmetic, 412-413
- compound, 153
- conditional, 411
- negating, 155
- reusing, 254
- symbolic, 78
F
- false command, 409
- fc command, 409
- fg command, 92, 409
- fi statement, 409
- field editing, awk command, 261-262
- fields, 261
- file attributes, tar command, 359
- file command, 71
- file descriptors, 204
- associating files with, 204-205
- redirecting, 207
- STDERR, 204
- STDIN, 204
- STDOUT, 204
- file handles. See file descriptors
- file systems, 358
- file types, determining, 70
- filename substitution. See globbing
- FILENAME variable, 273
- filenames, 52
- case-sensitive, 53
- length of, 53
- rules for expansion, 416
- setting to lowercase, 402
- spaces, 53
- special characters, 137
- files
- appending output to, 199
- as leaves, 52
- associating with descriptors, 204-205
- block special, 73
- changing groups, 81
- changing owners, 81
- restrictions, 82
- character special, 73
- copying, 45-47
- copying with directories, 63
- counting characters, 44
- counting lines, 43
- counting words, 42-44
- determining full pathname, 400
- device, 73
- file command, 71
- filtering
- grep command, 226-230
- head command, 224-225
- tail command, 225-226
- finding with find command, 290
- greping every file in a directory, 400
- hidden, 39-40
- interprocess communication, 74
- listing, 38-39, 60
- listing lines, 227
- locating, 400
- manipulating with for loop, 166-167
- most recently accessed, listing, 224
- named pipes, 74
- nohup.out, 92
- option grouping, 40
- ownership, 74
- passwords stored, 76
- permissions
- changing, 77-81
- viewing, 75
- printing input lines with awk, 260
- read permissions, 75
- reading, redirection, 208-209
- regular, 70
- relative pathnames, 55
- removing, 48
- removing carriage returns 403
- removing temporary files with matching names, 401
- renaming, 47, 401-402
- with tar, 364
- SGID permission, 76-77
- shell initialization, 26
- shortcuts. See symbolic links
- socket, 74
- STDERR, 204
- STDIN, 204
- STDOUT, 204
- SUID permission, 76-77
- symbolic links, 71-72
- common errors, 72-73
- temporary, cleaning up, 310-312
- test command, 148
- compound expressions, 153-156
- numerical comparisons, 151-152
- string comparisons, 149-151
- test commands, 411
- viewing contents, 41
- numbering lines, 42
- filtering text
- awk command, 259-261
- comparison operators, 263-266
- field editing, 261-262
- flow control, 275-279
- pattern-specific actions, 262-263
- STDIN as input, 266-267
- variables, 267-275
- grep command, 226
- line numbers, 229
- listing filenames, 230
- searching for words, 227-228
- head command, 224-225
- sed command, 250
- tail command, 225
- follow option, 226
- find command, 289-290, 400
- -atime option, 293
- -ctime option, 293
- -exec action, 295
- -mtime option, 293
- -n option, 291-292
- -print action, 295
- -size option, 294
- -type option, 292
- combining options, 294
- multiple directories, 291
- negating options, 295
- quoting wildcards, 138
- starting directory, 290-291
- finding files (find command), 400
- floating point numbers, awk command, 273
- flow control
- awk command, flow control, 275-279
- case statement, 156
- patterns, 157
- if statement, 144-145
- common errors, 145-147
- test, 147
- compound expressions, 153-156
- file tests, 148
- numerical comparisons, 151-152
- string comparisons, 149-151
- for loops, 165-166, 409
- awk command, flow control, 278-279
- manipulating sets of files, 166-167
- foreground processes, 86-87
- fg command, 92
- moving to background, 90-92
- forked child processes, 99
- format specifications, printf command, 195, 197-198
- formatting output
- echo command, 192-194
- printf command, 195-198
- forward slash (/), 53, 243
- sed command, 253
- FS property (awk command), 273
- function libraries
- checking disk space, 344-347
- displaying messages, 337-339
- libTYSP.sh, 350-354
- naming conventions, 335-336
- retrieving process ID name, 348-349
- retrieving user numeric user ID, 349-350
- user input, 339-342
- prompting for response, 342-344
- function libraries, 334-337
- function statement, 409
- functions
- AlarmHandler, 314
- common uses, 212
- customizing path with, 214-216
- debugging, set command, 320
- debugging hooks, 329
- definitions, 211-212
- determining UNIX version, 386
- dirs, 217
- echo_prompt, 388
- getFreeSpace, abstaction, 389-390
- getopts, 371
- getOSName, 386
- getPID, 348, 390-391
- getUID, 350
- including in shell scripts, 335
- including variables definitions in other files, 397
- invoking, 212
- listing path with, 213-214
- main code, 334
- popd, 219
- wrapper, 220
- popd_helper, 219-220
- printERROR, 338-339
- printUSAGE, 339
- printWARNING, 338
- promptRESPONSE, 342
- promptYESNO, 339
- pushd, 217-219
- replacing binaries with, 212
- replacing shell built-ins with, 212
- SetTimer, 314-315
- sharing data between, 216
- UnsetTimer, 315
G
- general input/output redirection, 205
- getFreeSpace function, abstraction, 389-390
- getopts command, 176, 183-187, 409
- getopts function, 371
- getOSName function, 386
- getPID function, 348
- abstraction, 390-391
- getUID function, 350
- globally regular expression print. See grep
- globbing, 117
- * wildcard, 118-119
- ? wildcard, 120
- [] wildcard, 121
- matching sets of characters, 121-123
- matching suffixes and prefixes, 119
- GNU, gawk command, 260
- grep command, 226, 418
- -i option, 228
- -l option, 230
- -n option, 229
- -v option, 228
- address book, extracting names, 366
- greping a string in every file, 400
- line numbers, 229
- listing filenames, 230
- regular expressions, quoting, 137
- searching for words, 227-228
- groups, 81-82
H
- hardware, determining, 384-385
- head command, 224-225
- help. See online help
- here documents, 201-202, 417
- hidden directories, 40
- hidden files, 39-40
- history command, 409
- home directories, 56
- HOME variable, 115, 415
- hostname command, 385
- HP-UX
- /bin, /sbin directories, 383
- abstraction, getFreeSpace function, 389-390
- remote system command, 387
- wc command, counting file characters, 44
- HUP signals, 308
I
- IEEE, awk standard, 260
- if statement, 144-145, 409
- -f option, 148
- n option, 150
- s option, 148
- z option, 150
- awk command, flow control, 275-277
- common errors, 145-147
- compound expressions, 154
- script portability, 387
- syntax checking, 321
- if-then-else statements, abbreviating with variable substitution, 123
- IFS variable, 115, 415
- ignoring signals, 312-313
- index numbers, 108
- arrays variables, accessing, 110
- infinite loops
- : character, 287
- break command, 169-170
- continue command, 171
- initialization scripts
- accessing current shell name, 394
- cross-platform, PATH variable, 214
- initializing shell, file contents, 28-29
- inner loops, 161
- input, 200
- background processes, 89
- pipelines, 203
- printing lines with awk, 260
- reading, 202-203
- redirecting, 200-201
- general redirection, 205
- here documents, 201-202
- while loops, 202
- xargs command, 296
- installation scripts, disk usage 345
- INT signals, 308
- integer arithmetic, 297
- integer statement, 409
- integers, test commands, 412
- interactive mode, 27
- address book 368
- login, 27
- interactive shells, 395
- interpreter, 394
- interprocess communication, 74
- intializing shell, 26
- invisible files. See hidden files
- invocation activated debugging modes, 318
- invoking functions, 212
J - K
- job controls
- determining if available to shell 397
- jobs command, 94, 409
- kill command, 97
- Joy, Bill, 16
- kernel, 24
- accessing features with system calls, 394
- kill command, 97, 409
- -l option, 306
- signals, 307
- kill signals, 308-309
- Korn shell (ksh), 17-18
- array variables, 108
- exporting variables, 114
- integer expressions, 412-413
- parameter substitution, 415-416
- starting C Shell from, 99
- support arrays, 414
- until loop, 164
- wildcards, 416
- Korn, David, 17
L
- leaves, 52
- let command, 409
- libraries
- checking disk space, 344-347
- displaying messages, 337-339
- libTYSP.sh, 350-354
- naming conventions, 335-336
- retrieving process ID name, 348-349
- retrieving user numeric user ID, 349-350
- user input, 339-342
- prompting for response, 342-344
- libraries, 334-337
- libTYSP.sh shell library, 350-354
- line numbers, grep command, 229
- Linux
- compared to BSD and System V, 383
- gawk command, 260
- shell tracing, 326
- wc command, counting file characters, 44
- listing paths, with functions, 213-214
- listing signals, 306
- listings
- addperson script, 369-370
- delperson script, 373-374
- mvdir.sh script, 360-362
- showperson script, 366
- literal characters, 130
- ln command, -s option, 72
- local variables, 112
- logging in, 24-26
- logic, checking with shell tracing, 328-329
- logins
- logging, 289
- starting shell interactively, 27
- starting shell noninteractively, 27
- looping
- controlling
- break command, 169-170
- continue command, 171
- for, 165-166
- manipulating sets of files, 166-167
- infininite loops, 169-170
- continue command, 171
- nested loops, 170
- select, 167-168
- changing prompt, 169
- until, 164
- while, 160-161
- input redirection, 202
- nesting, 161-162
- until loop, 164-165
- validating user input, 162-163
- lowercase, setting filenames to, 402
- ls command, 38-39
- -1 option, 39
- -a option, 39
- -d option, 70
- -F option, 38
- -l option, 70, 75
- character special files, 73
- directories, 59
- file types, determining, 70
- files, 60
- option grouping, 40
M
- mail command, quoting with embedding spaces, 135
- mail spools, listing oldest, 225
- main code, 334
- main loops, 161
- man pages, 31-33
- signals, 306
- MANPATH variable, 29
- manuals, 33
- matching
- find command -name option, 291
- sets of characters, 246
- strings, 248
- memory, 24
- messages. See also output
- displaying
- function libraries, 337-339
- STDERR, 396
- printing, to STDOUT, 207
- metacharacters, 130, 243-244
- double quotes, 132-134
- escaping, 248-249
- quoting with backslash, 130-131
- single quotes, 131-132
- misspellings, correcting with sed command, 252
- mkdir command, 61
- common errors, 62
- parent directories, 61
- modified dates, finding files with find command, 293
- modulus function, 298
- moving directories
- examples, 364-365
- mvdir.sh, 360-364
- tar files, 358-359
- mv command, 47, 63
- common errors, 64-65
- interactive mode, 47
- limitations, 358
- renaming files, 401
- mvdir.sh script, 360-364
N
- name value pairs, 106
- named pipes, 74
- naming conventions
- function libraries, 335-336
- variables, 106-107
- nawk command, 260
- negating a set, 246
- nesting, 161
- loops, breaking infinite loops, 170
- while loops, 161-162
- networking, System V UNIX, 382
- newgrp command, 409
- newline character, 135
- converting to spaces, 232
- next command, comparison operators, 265-266
- no-op command (:), 124, 287
- nohup command, 92
- nohup.out file, 92
- noninteractive mode, 27
- address book, 369
- login, 27
- noninteractive shells, determining, 395
- numbers, sorting, 235
- different columns, 235-236
- numeric expressions, 268
- awk command
- assignment operators, 270
- built-in variables, 272-274
- shell variables, 274-275
- special patterns, BEGIN, END, 271-272
- numeric tests, 327
O
- octal method, chmod command, 80
- online help
- man command, 31-33
- MANPATH variable, 29
- operands, expr command, 297
- operators
- ||, 153
- !, 153
- !=, test command, 151
- &&, 153
- <<, here documents, 201
- comparison, 263
- Korn/Bash integer expressions, 412-413
- OPTARG variable, 415
- OPTIND variable, 415
- option grouping, files, 40
- option parsing, 183-184
- getopts command, 184-187
- options, 178
- combining, find command, 294
- compared to arguments, 178
- debugging options, 318
- negating, find command, 295
- ps command, 96
- uname command, 383
- or-or operator (||), 265
- outer loops, 161
- output, 189
- background processes, 90
- redirecting
- general redirection, 205
- pipelines, 203
- reading files, 208-209
- redirecting to /dev/null, 395
- redirection, 198
- appending to files, 199
- to files and screens, 199-200
- STDERR, 190
- redirecting, 205-207
- STDOUT, 190
- printing messages to, 207
- redirecting, 205-207
- to terminal, 190
- echo command, 190-194
- printf command, 194-198
- owners, 81-82
- files, 74
P
- parameters, substitution, 415-416
- parent directories, 52, 61
- parent processes, 98-100
- passwd command, SUID bit, 77
- passwd file, login, 25
- passwords
- file stored in, 76
- process permissions, 100
- logging in, 25
- PATH variable, 115, 415
- cross-platform initialization scripts, 214
- setting, 28
- pathnames, 53-54
- .. leader, 55
- absolute, 54
- determining directory full pathnames, 399
- determining file full pathnames, 400
- displaying for a command, 288
- displaying for files, 289
- find command, 290
- relative, 55-56
- paths
- absolute, 52
- customizing, with functions, 214-216
- listing, with functions, 213-214
- pattern matching, 416
- awk command, 262
- if statement, 275
- patterns, 243
- [0-9]*, 298
- .*, 298
- anchoring, 247-248
- percent sign (%)
- job number prefixes, 91
- prompt, 15
- permissions
- changing with chmod command, 77
- common errors, 81
- octal method, 80
- symbolic expression, 78-80
- definition of, 75
- directory, 76
- file ownership, 74
- files, viewing, 75
- moving files with tar command, 359
- octal expression values, 80
- processes, 100
- read, 76
- SGID file permission, 76-77
- SUID file permission, 76-77
- world read, 79
- world write, 79
- write, 76
- pid (process ID), 86
- pipe character (|)
- tar files, 359
- tr command, 232
- pipelines, 203
- sed command, 255-256
- piping, 74
- most recently accessed files, 225
- plus (+) character, shell tracing, 325
- popd function, 219
- wrapper, 220
- popd_helper function, 219-220
- portability
- abstraction, 389-391
- conditional execution, 387-388
- determining versions with a function, 385-386
- hardware type, 384-385
- improving, 387
- uname command, 383-384
- UNIX versions, 381
- POSIX, awk, 260
- pound sign (#), comments, 30
- prefixes, matching in globbing, 118
- print command, 409
- with awk, 261-262
- printERROR function, 338-339
- printf command, 262, 341, 419
- output, 194
- formatting, 195-198
- printing
- lines with sed command, 250-251
- messages, to STDOUT, 207
- printUSAGE function, 339
- printWARNING function, 338
- processes
- background, 87-89
- fg command, 92
- moving foreground processes to, 90-92
- preventing termination, 92
- waiting for, 93
- child, 98-100
- exec command, 100
- foreground, 86-87
- function libraries
- ID names, retrieving, 348-349
- user numeric user ID, retrieving, 349-350
- IDs, temporary files, 252
- job control IDs, determining availibility, 397
- job numbers, assigning, 92
- jobs command, 94
- kill command, 97
- limit, 86
- parent, 98-100
- ps command, 94-96
- starting, 86
- suspending, 90
- profile file, shell initialization, 28
- profiles, shell specific startup with $0 variable, 394
- programmer activated modes, 319
- programs
- executing with SGID bit, 76
- utilities, 24
- prompt
- background processes, 88
- changing with select loop, 169
- promptRESPONSE function 342
- prompts, 10
- Bourne shells, 15
- C shell, 15
- echo command, 388
- shell, 14
- promptYESNO function 339
- ps command, 94-96
- PS1 variable, 415
- PS2 variable, 415
- public directory, disk space, 346
- punctuation marks, embedding in output, 191
- pushd function, 217-219
- pwd command, 55, 409
- PWD variable, 114, 415
Q - R
- QUIT signals, 308
- quoting
- combining quoting, 134
- echo escape sequences, 137-138
- embedding spaces, 134-135
- filenames with special characters, 136
- newline character, 135-136
- wildcards, 137
- cpio and find commands, 138
- with backslash, 130-131
- with double quotes, 132-134
- with single quotes, 131-132
- word boundaries, 134
- r command, 409
- RANDOM variable, 114, 415
- read command, 202, 341, 410
- read permission, 75-76
- read-only variables, 111
- reading
- files, redirection, 208-209
- input, 202-203
- readonly command, 111, 410
- redirecting
- file descriptors, 207
- input, 200-201
- general redirection, 205
- here documents, 201-202
- while loops, 202
- output, 198
- appending to files, 199
- general redirection, 205
- pipelines, 203
- reading files, 208-209
- STDOUT, 205-207
- to files and screens, 199-200
- redirection signs, eval command, 286
- regular expressions, 241
- [0-9]*, 298
- .*, 298
- awk command, 242-244
- anchoring patterns, 247-248
- escaping metacharacters, 248-249
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- sets of characters, 245-246
- quoting, 137
- sed command, 242-244, 250
- anchoring patterns, 247-248
- escaping metacharacters, 248-249
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- sets of characters, 245-246
- wildcards, 419-420
- regular files, 70
- relative paths
- find command, 291
- moving directories, 363
- remainders, 298
- remote commands, conditional execution, 387
- remote shell (remsh, rsh, rcmd, remote) command, 300-301
- removing files, 48
- renaming files, 401-402
- interactive mode, 47
- with tar command, 364
- REPLY variable, 114, 415
- return command, 410
- reversing a set, 246
- rm command, 65
- -r option, 67
- common errors, 48
- interactive mode, 48
- rmdir command, 66-67
- root, 52
- absolute pathnames, 54
- root accounts, 15
- rsh command, 387
- running commands, 10
S
- scalar variables, 106
- scale (bc command), 299
- scripts
- $0 shell variable, 177
- comments, 30
- globbing, 118
- including functions 335
- maintenance, 178
- operation failures, 182
- option parsing, 183-184
- getopts command, 184-187
- variable substitution, 124
- while loop, 160-161
- nesting, 161-162
- until loop, 164-165
- validating user input, 162-163
- searching files with wildcards, 122
- SECONDS variable, 115, 415
- sed command, 242-244, 250
- anchoring patterns, 247-248
- deleting lines, 251-252
- escaping metacharacters, 248-249
- matching characters, 244-245
- matching sets of characters, 246
- metacharacters, 243-244
- multiple sed commands, 255
- pipelines, 255-256
- printing lines, 250-251
- sets of characters, 245-246
- substitutions, 252-254
- using shell variables in, 398
- select command, 410
- select loops, 167-168
- changing prompt, 169
- semicolon (;), 12-13, 130
- awk command, 261
- if then statement, 145
- separators, commands, 13
- set command, 319-320, 410
- -x option, 324
- SetTimer function, 314-315
- SGID file permission, 76-77
- sh, 16
- prompts, 15
- shadow file, 76
- shell libraries, libTYSP.sh, 350-354
- shell prompt, 14
- shell scripts, 9, 28
- debugging, 318-322
- set command, 319-320
- verbose mode, 322-324
- file output, ls -l command, 39
- portability
- abstraction, 389-391
- conditional execution, 387-388
- determining versions with a function, 385-386
- hardware type, 384-385
- improving, 387
- UNIX versions, 383
- shell tracing, 324-325
- debugging, single functions, 320
- debugging hooks, 329-331
- disabling, 320
- logical bugs, 328-329
- set command, 319
- syntax bugs, 325-327
- shell variables, 113-114, 176
- shells, 14, 24
- accessing name, 394
- awk command variables, 274-275
- bash, 19
- Bourne-type, 15
- built-in variables, 414
- built-ins, replacing with functions, 212
- C-type, 15
- csh, 16-17
- prompts, 15
- determining job control availability, 397
- find commands, 396
- initializing, 26
- file contents, 28-29
- interactive mode, 27
- ksh, 17-18
- login, 24-26
- making scripts executable, 29-30
- noninteractive mode, 27
- remote shell command, 300
- scripts, comments, 30
- sh, 16
- prompts, 15
- subshells, 99
- tcsh, 17
- uninitialized, 26
- using varaibles in sed command, 398
- variables, listed, 415
- shift command, 185, 410
- SHLVL variable, 114, 415
- shortcuts. See symbolic links
- showperson script, 366
- signals, 305-306
- ALARM, 313-314
- example timer script, 315-316
- handler function, 314
- setting timer, 314-315
- unsetting timer, 315
- cleaning up temporary files, 310-312
- default actions, 307
- delivering, 307
- HUP, 308
- ignoring, 312-313
- INT, 308
- kill, 308-309
- kill command, 307
- listing, 306
- man pages, 306
- QUIT, 308
- setting actions, 309
- TERM, 308
- SIGTTOU message, 90
- simple commands, 11
- single quote (), 131-132
- awk and sed commands, 242
- filtering, 237
- slash (/) character, 53
- sleep command, 288-289
- socket files, 74
- Solaris
- uname command, 384
- wc command, counting characters, 44
- sort command, 233, 419
- -k option, 236
- -n option, 236
- -r option, 236
- sorting numbers, 235
- spaces
- converting tabs/newlines to, 232
- filenames, 53
- removing with tr command, 232-233
- special characters
- backslash (\), 130
- filesnames, accessing by quoting, 136
- special variables, 176
- $0, 176-177
- usage statements, 177-178
- stacks
- csh, 217
- directory
- adding directories to, 217-219
- listing, 217
- manipulating (popd function), 219-220
- storing, 217
- stacks 216
- standard errors. See STDERR
- standard input, xargs command, 296
- standard output. See STDOUT
- statements
- case, 156-157
- if, 144-147
- STDERR (standard error), 190, 204
- displaying messages on, 396
- redirecting, 205-207
- redirecting function messages to, 337
- STDIN (standard input), 204
- extracting tar files from, 359
- grep command, 228
- input for awk command, 266-267
- STDOUT (standard output), 190, 204
- outputing to with tar command 359
- printing messages to, 207
- redirecting, 205-207
- stream editor, 241
- strings
- matching, 248
- quoting, 131
- test commands, 411
- stty command, addperson script, 371
- subdirectories, 52
- subshells, 99-100
- relative paths, moving directories, 363
- substitution (variables)
- embedding in output, 191
- sed command, 252-254
- suffixes, matching in globbing, 119
- SUID file permission, 76-77
- octal expression values, 80
- SunOS, uname command, 384
- support arrays, 414
- suspending processes, 90
- symbolic expressions, chmod command, 78-80
- symbolic links, 71-73
- syntax
- checking with shell tracing, 325-327
- debugging, 320-322
- verbose mode, 322-324
- debugging mode, 318
- system calls, 394
- System V, versus BSD, 382-383
T
- tabs, converting to spaces, 232
- tail command, 225
- -f optio, 226
- follow option, 226
- tar files, 359
- arguments, 179
- listing contents with $0 variable, 177
- tcsh, 17
- temporary files
- appending process IDs, 252
- cleaning up, 401
- trap command, 310-312
- TENEX/TOPS C shell, 17
- TERM (value 15) signal, 97
- TERM signals, 308
- terminals
- output to, 190
- echo command, 190-194
- printf command, 194-198
- setting type, 28
- test -t command 395
- test command, 147, 410
- compound expressions, 153-156
- file test options, 148
- file tests, 148
- numerical comparisons, 151-152
- string comparisons, 149-151
- text files, filtering
- awk command, 259-279
- grep command, 226-230
- head command, 224-225
- tail command, 225-226
- then statement, troubleshooting, 145
- timers, ALARM signals, 313-314
- example timer script, 315-316
- handler function, 314
- setting timer, 314-315
- unsetting timer, 315
- tr command, 231-232
- -s option, 232
- character classes, 236-238
- removing carriage returns, 403
- removing spaces, 232-233
- versions of, 232
- tracing, 324-325
- debugging hooks, 329-331
- disabling, 320
- logical bugs, 328-329
- set command, 319
- syntax bugs, 325-327
- transliterating words, tr command, 231
- trap command, 309, 410
- cleaning up temporary files, 310-312
- trees, 52
- troubleshooting
- address book 368
- arguments, 180-182
- background processes, 89
- tty -s command 395
- type command, 288, 410
- typeset command, 410
U
- UID variable, 114, 415
- ulimit command, 410
- umask command, 410
- unalias command, 410
- uname command, 383-384
- -m option, 384
- -r option, 384
- determining versions with a function, 385-386
- hardware type, 384-385
- SunOS, 384
- uniq command, 233-234
- UNIX
- kernel, 24
- system manuals, 33
- unset command, 112, 410
- UnsetTimer function, 315
- unsetting variables, 112
- until loop, 164-165, 410
- usage statements, $0 variable, 177-178
- user accounts, 15
- user IDs, retrieving, 349
- user input
- function libraries, 339-344
- validating with while loop, 162
- user-defined variables, 414
- users. See also input
- logging in, 24-26
- logging logins with sleep command, 289
- process ID, 96
- profiles, shell specific startup with $0 variable, 394
- shell, interactive mode, 27
- utilities, 24
- uuencode, 184
- option parsing, 186
V
- validating user input, while loops, 162-163
- variable substitution, 117, 123
- default values
- assigning, 124
- substituting, 123
- option parsing, 185
- single quotes, 132
- variable errors, 124
- variables
- $0, 176-177
- usage statements, 177-178
- $0, 394
- $?, 396
- arguments, troubleshooting, 180-182
- arrays, 106-110
- accessing values, 110-111
- awk command, 267-268
- numeric expressions, 268-275
- built-in shell, 414
- checking for values, 399
- considering arguments one at a time, 397
- defining, 105
- DIR STACK, 217
- environment, 112
- exporting, 113
- FILENAME, 273
- including functions and definitions in other files, 397
- local, 112
- naming, 106-107
- PATH, cross-platform initialization scripts, 214
- read-only, 111
- scalar, 106
- sed command, using shell variable values in, 398
- shell, 113-114
- listed, 415
- special, 176
- substitution, embedding in output, 191
- unsetting, 112
- user-defined, 414
- validating user input, 163
- values, 107
- verbose mode, 322-324
- versions
- awk command, 260
- determining, 381, 385-386
- mv command, 358
- ps command, 94
- remote shell command, 300
- test -t command, 395
- tr command, 232
- tty -s command, 395
- uname command, 383-384
- hardware type, 384-385
- viewing
- file contents, 41
- numbering lines, 42
- file permissions, 75
W - Z
- wait command, 93, 410
- wc command, 42-43
- -c option, 44
- -l option, 43
- -w option, 44
- grouping options, 44
- Web browsers, sockets, 74
- whence command, 410
- while loops, 160-161, 410
- awk command, flow control, 277
- input redirection, 202
- nesting, 161-162
- until loop, 164-165
- validating user input, 162-163
- who command, 11
- wildcards, 416. See also metacharacters
- expr command, 299
- find command, 292
- globbing, 118
- * wildcard, 118-119
- ? wildcard, 120
- [] wildcard, 121
- matching sets of characters, 121-123
- quoting, 137
- with cpio and find, 138
- regular expression, 419-420
- words
- count occurances, 233
- counting, 231
- transliterating, 231-232
- world read permission, 79
- world write permission, 79
- wrapper scripts, forwarding arguments onto other commands, 398
- write permission, 76
- xargs command, 296-297
- zero completion code, 287