UNIX and Shell programming : a textbook /
Forouzan, Behrouz A.
UNIX and Shell programming : a textbook / Behrouz A. Forouzan and Richard F. Gilberg. - Pacific Grove, CA : Brooks/Cole-Thomson Learning, c2003. - xix, 875 p. : ill. (some col.) ; 24 cm.
Includes index.
1.1 Why UNIX? 3
Portable 3
Multiuser 3
Multitasking 3
Networking 4
Organized File System 4
Device Independence 4
Utilities 4
Services 4
1.2 Computer System 4
Hardware 5
Software 5
The Operating System 6
1.3 The UNIX Environment 6
Personal Environment 6
Time-Sharing Environment 7
Client/Server Environment 7
1.4 UNIX Structure 8
The Kernel 8
The Shell 8
Utilities 9
Applications 10
1.5 Accessing UNIX 10
User ID 10
Passwords 10
Interactive Session 11
1.6 Commands 13
Basic Concepts 13
1.7 Common Commands 15
Date and Time (date) Command 15
Calendar (cal) Command 17
Who's Online (who) Command 18
whoami 20
Change Password (passwd) Command 20
Print Message (echo) Command 21
Online Documentation (man) Conunand 22
Print (Ipr) Command 23
1.8 Other Useful Commands 24
Terminal (tty) Command 24
Clear Screen (clear) Command 25
Set Terminal (stty) Command 25
Record Session (script) Command 27
System Name (uname) Command 28
Calculator (be) Command 29
1.9 Key Terms 32
1.10Tips 32
1. 11 Commands 33
1.12 Summary 34
1.13 Practice Set 35
Review Questions 35
Exercises 36
1.14 Lab Sessions 37
^asoc m 4 i
2.1 Editor Concepts 41
Line Editors 41
Screen Editors 41
2.2 The vi Editor 42
2.3 Modes 42
Command Mode 43
Text Mode 43
Changing Modes 43
2.4 Commands 44
Add Commands 44
Cursor Move Commands 46
Deletion Commands 50
Join Command 50
Scrolling Commands 51
Undo Commands 53
Saving and Exit Commands 54
2.5 Two Practice Sessions 55
2.6 Key Terms 57
2.7 Tips 57
2.8 Commands 57
2.9 Summary 58
2.10 Practice Set 60
Review Questions 60
Exercises 60
2.11 Lab Sessions 62
Fe^e Systems 6S
3.1 Filenames 65
Wildcards 66
3.2 File Types 68
3.3 Regular Files 69
Text Files 69
Binary Files 69
3.4 Directories 70
Special Directories 70
Paths and Pathnames 71
Relative Pathname Abbreviations 72
3.5 File System Implementation 75
File Systems 76
Directory Contents 77
Links 77
3.6 Operations Unique to Directories 80
Locate Directory (pwd) Command 80
List Directory (Is) Command 81
Make Directory (mkdir) Command 86
Change Directory (cd) Command 88
Remove Directory (rmdir) Command 89
3.7 Operations Unique to Regular Files 89
■ Create File 89
Edit File 89
Display File (more) Command 90
Print File 92
3.8 Operations Common to Both 93
Copy (cp) Command 93
Move (mv) Command 100
Rename (mv) Command 102
Link (In) Command 102
Remove (rm) Command 106
3.9 Key Terms 112
3.10 Tips 112
3.11 Commands 113
3.12 Summary 114
3.13 Practice Set 115
Review Questions 115
Exercises 116
3.14 Lab Sessions 119
Chapter 4
Security and
FiSe Perai^ss9©8? ! 11
4.1 Users and Groups 121
Group (groups) Command 121
4.2 Security Levels 122
System Security 122
Permission Codes 123
Checking Permissions 126
4.3 Changing Permissions 126^
Symbolic Codes 127
Octal Codes 128
Option 130
4.4 User Masks 131
Basic Concept 131
User Mask (umask) Command 132
4.5 Changing Ownership and Group 132
Change Ownership (chown) Command 133
Change Group (chgrp) Command 133
4.6KeyTerms 134
4.7 Commands 134
4.8 Tips 135
4.9 Summary 135
4.10 Practice Sets 136
Review Questions 136
Exercises 138
4.11 Lab Sessions 140
SgntiTsdiBfStk&in} to Sii'33S^-i
5.1 UNIX Session 144
Login Shell Verification 145
Current Shell Verification 145
Shell Relationships 145
Logout 146
5.2 Standard Streams 146
5.3 Redirection 147
Redirecting Input 147
Redirecting Output 148
Redirecting Errors 149
5.4 Pipes 151
5.5 tee Command 153
5.6 Command Execution 154
Sequenced Commands 155
Grouped Commands 155
Chained Commands 156
Conditional Commands 156
5.7 Command-Line Editing 156
Command-Line Editing Concept 157
Editor Selection 157
vi Command-Line Editor 157
Using the Conrunand-Line Editor 159
5.8 Quotes 159
Backslash 160
Double Quotes 161
Single Quotes 163
5.9 Command Substitution 164
5.10 Job Control 165
Jobs 165
Foreground and Background Jobs 165
jobsConunand 168
Process ID 170
5.11 Aliases 170
Aliases in the Kom and Bash Shells 171
Aliases in the C Shell 174
Alias Summary 176
5.12 Variables 176
User-Defined Variables 176
Predefined Variables 177
Storing Data in Variables 177
Accessing a Variable 178
5.13 Predefined Variables 178
Handling Variables 181
5.14 Options 183
Handling Options 184
5.15 Shell/Environment
Customization 185
Temporary Customization 185
Permanent Customization 185
Summary 187
5.16 Key Terms 188
5.17 Tips 188
5.18 Commands 189
5.19 Summary 191
5.20 Practice Set K92
Review Questions 192
Exercises 193
5.21 Lab Sessions 197
COnapteif 6
FiSteE's f!
6.1 Filters and Pipes 202
6.2 Concatenating Files 202
Catenate (cat) Command 202
cat Options 205
6.3 Display Beginning and End
of Files 207
head Command 207
tail Command 208
6.4 Cut and Paste 210
cut Command 210
paste Command 214
6.5 Sorting 217
sort Command 217
Sort by Lines 217
Sdrt by Fields 219
Options 222
Multiple-Pass Sorting 227
6.6 Translating Characters 230
tr Command 230
Simple Translate 230
Nonmatching Translate Strings 231
Delete Characters 231
Squeeze Output 231
Complement 232
6.7 Flies with Duplicate Lines 233
uniqConunand 233
Output Format 234
Skip Leading Fields 236
Skip Leading Characters 236
6.8 Count Characters, Words,
or Lines 237
wc Command 237
6.9 Comparing Flies 238
Compare (cmp) Command 238
Difference (diff) Command 240
Common (conun) Command 243
6.10 Key Terms 244
6.1 i Tips 244
6.12 Commands 245
6.13 Summary 246
6.14 Practice Set 247
Review Questions 247
Exercises 248
4.15 Lab Sessions 252
Ciiapter 1
€©mBiniim^Q€ait3®ins
%%1
7.1 User Communication 257
talk Command 257
write Conunand 260
7.2 Electronic Mail 262
Mail Addresses 262
Mail Mode 265
mail Command 265
Send Mail 265
Read Mode 270
Read Mail Options 275
Mail Files 275
7.3 Remote Access 276
The telnet Concept 276
Connecting to the Remote
Host 278
7.4 File Transfer 279
The ftp Command 279
Establishing ftp Connection 280
Closing an ftp Connection 280
Transferring Files 281
7.5 Key Terms 282
7.6 Commands 283
7.7 Tips 283
7.8 Summary 284
7.9 Practice Set 285
Review Questions 285
Exercises 286
7.10 Lab Sessions 287
CBnaipter ®
vi GX 19 D
8.1 vl Editor 292 ^
Commands 292
Conunand Categories 293
8.2 Local Commands
in vi 293
Insert Text Conunands (i, I) 293
Append Text Comniands (a. A) 293
Newline Conunands (o, O) 294
Replace Text Commands (r, R) 294
Substitute Text Conunands (s, S) 295
* Delete Character
Conunands (x, X) 295
Mark Text Command (m) 296
Change Case Command (~) 296
Put Commands (p, ?) 297
Join Conunand (J) 298
8.3 Range Commands in vi 299
Text Object 299
Text Object Conunands 304
Yank Conunand 306
Range Command Summary 307
8.4 Global Commands in vi 307
Scroll Commands 307
Undo Commands 307
Repeat Command 308
Screen Regeneration Commands 308
Display Document Status Line 308
Save and Exit Commands 309
8.5 Rearrange Text in vi 309
Move Text. 309
Copy Text 309
Named Buffers 310
8.6 ex Editor 311
ex Instruction Format 311
Addresses 312
Commands 316
8.7 Key Terms 320
8.8 Tips 320
8.9 Commands 321
8.10 Summary 323
8.11 Practice Set 324
Review Questions 324
Exercises 325
8.12 Lab Sessions 326
Chaptcir 9
Kegaaiar 33 B
9.1 Atoms 331
Single Character 332
Dot 332
Class 333
Anchors 334
Back References 335
9.2 Operators 335
Sequence 335
Alternation 337
Repetition 337
Group Operator 341
Save 342
9.3 Key Terms 343
9.4 Tips 343
9.5 Summary 344
9.6 Practice Set 344
Review Questions 344
Exercises 345
CSnapte:." 1 ©
giy-ejn)
10.1 Operation 351
grep flowchart 352
grep Operation Example 352
10.2 grep Family 354
grep 355
Fast grep 356
Extended grep 356
10.3 Examples 359
10.4 Searching for File Content 362
Search a Specific Directory 362
Search All Directories in a Path 363
10.5 Key Terms 364
10.6 Tips 364
10.7 Commands 365
10.8 Summary 365
10.9 Practice Set 366
/
Review Questions 366
Exercises 366
10.10 Lab Sessions 368
CBuiapjteir B i
sesi 373
11.1 Scripts 373
Script Formats 374
Instruction Format 374
Comments 374
11.2 Operation 375
11.3 Addresses 377
Single-Line Addresses 378
Set-of-Line Addresses 379
Range Addresses 380
Nested Addresses 381
11.4 Commands 381
Line Number Command 381
Modify Commands 382
Substitute Command (s) 386
Substitute Flags 39!
Transform Command (y) 393
Input and Output Commands 394
File Commands 399
Branch Commands 401
Hold Space Commands 404
Quit 405
11.5 Applications 406
Delete Lines 406
Delete Text 408
11.6 grep and sed 409
Lines That Match a Regular
Expression 409
Lines That Do Not Match a Regular
Expression 410
11.7 Key Terms 411
11.8 Tips 411
11.9 Commands 412
11.10 Summary 413
11.11 Practice Set 414
Review Questions 414
Exercises 416
11.12 Lab Sessions 421
Chapter 12
awk 42S
12.1 Execution 425
12.2 Fields and Records 426
Buffers and Variables 426
Variables 427
12.3 Scripts 428
Initialization Processing
(BEGIN) 428
Body Processing 429
End Processing (END) 429
12.4 Operation 429
12.5 Patterns 431
Simple Patterns 432
Nothing (No Pattern) 436
Range Patterns 436
12.6 Actions 438
Expression Statement 439
Output Statements 440
Decision Statements 444
Control Actions 446
Loops 449
12.7 Associative Arrays 453
Processing Arrays 454
Delete Array Entry 459
12.8 String Functions 459
Length 460
Index 460
Substring 461
Split 463
Substitution 464
Global Substitution 465
Match 466
ToupperandToIower 466
12.9 Mathematical
Functions 467
12.10 User-Defined
Functions 468
12.11 Using System Commands in
awk 469
Using Pipes 469
Using the System Function 471
12.12 Applications 472
Phone List 472
Count Lines and Words 473
Print Line Following a Blank
Line 473
Print Line Before a Blank
Line 474
Merge Files 474
12.13 awk and grep 475
Find the Line That Matches a Regular
Expression 475
Find the Line That Does Not Match a Regular
Expression 476
12.14 sed and awk 477
Print Line Numbers 477
Modify a Line 478
Substitute 479
Transform 479
Input/Output 480
Files 480
Branch 480
Quit 480
12.15 Key Terms 481
12.16 Tips 481
12.17 Commands 482
12.18 Summary 483
12.19 Practice Set 484
Review Questions 484
Exercises 486
12.20 Lab Sessions 488
Ctepter 13
13.1 Kom Shell Features 499
Kom Shell Sessions 499
Standard Streams 499
Redirection 499
Pipes 500
tee Command 500
Combining Commands 501
Command-Line Editing 501
Quotes 501
Conunand Substitution 501
Job Control 501
Aliases 502
13.2 Two Special Files 502
Trash File (/dev/null) 502
Terminal File (/dev/tty) 503
13.3 Variables 504
User-Defined Variables 504
Predefined Variables 505
Storing Values in Variables 505
Accessing the Value of a Variable 506
Null Variables 507
Unsetting a Variable 508
Storing Filenames 508
Storing File Contents 508
Storing Commands in a Variable 509
Read-Only Variables 509
Exporting Variables 510
Variable Attribute: The typeset
Conunand 512
13.4 Output 514
13.5 Input 516
Reading Word by Word 517
Reading Line by Line 517
Reading from a File 518
13.6 Exit Status of a Command 518
13.7 eval Command 519
13.8 Environmental Variables 521
Change Directory Path (CDPATH) 522
ffistory File Path (HISTFILE) 522
Home Path (HOME) 523
Login Name (LOGNAME) 523
Mailbox Pathname (MAIL) 523
Mail Check Interval (MAILCHECK) -§§4
Incoming Mail Paths (MAILPATH) 524
Directory Search Paths (PATH) 524
Primary Prompt (PSI) 524
Secondary Prompt (PS2) 526
Third Prompt (PS3) 526
Fourth Prompt (PS4) 526
User Input Default Variable (REPLY) 526
Login Shell Path (SHELL) 527
Terminal Description (TERM) 527
Handling Environmental Variables 527
13.9 Options 528
Export All (allexport) 528
Command-Line Editor (emacs and vi) 528
Ignore End-of-File (ignoreeof) 529
No Clobber in Redirection (noclobber) 529
No Execute (noexec) 529
No Global (noglob) 529
Verbosity (verbose) 529
Execute Trace (xtrace) 530
Handling Options 530
13.10 Startup Scripts 530
System Profile File 530
Personal Profile File 531
Environment File 531
Startup Process 532
13.11 Command History 532
History File 532
History Command 533
Redo Command (r) 535
Substitution in Redo Command 536
13.12 Command Execution
Process 536
Execution Steps 536
Command Execution Example 537
13.13 Key Terms 537
13.14 Tips 538
13. f 5 Commands 539
13.16 Summary 540
13.17 Practice Set 541
Review Questions 541
Exercises 542
13.18 Lab Sessions 544
CilDapteir 04
toirra SMIl
14.1 Basic Script Concepts 547
Script Components 547
Making Scripts Executable 549
Executing the Script 549
Script Termination (exit Command) 553
Arguments and Positional Parameters 554
14.2 Expressions 555
Mathematical Expressions 556
' Relational Expressions 557
File Expressions 559
Logical Expressions 560
Expression Type Summary 562
14.3 Decisions: Making Selections 562
if-then-else 562
Multiway Selection 567
14.4 Repetition 571
Command-Controlled and List-Controlled
Loops 571
Background Loops 580
Loop Redirection 580
14.5 Special Parameters and
Variables 585
Special Parameters 585
Special Variables 588
Special Parameter and Variable
Summary 588
14.6 Changing Positional
Parameters 589
shift Command 591
14.7 Argument Validation 593
Number of Arguments Validation 593
Type of Argument Validation 594
14.8 Debugging Scripts 597
Debug Options Included in the Script 597
Debug Options on the Command Line 598
14.9 Script Examples 601
Cat 601
Copy 603
14.10 Key Terms 604
14.11 Tips 605
14.12 Commands 605
14.13 Summary 607
14.14 Practice Set 608
Review Questions 608
Exercises 609
14.15 Lab Sessions 613
C&napiseir IS
$3^eSi
P'rfSgrammoBig 6 8 7
15.1 Variable Evaluation and
Substitution 617
Variabje Evaluation 617
Variable Substitution 618
15.2 String Manipulation 622
Compress Strings 622
String L.ength 623
Locating a Substring in a
String 624
Extraa Substnng 625
Stripping Strings 626
Using Other Utilities 627
15.3 Here Document 628
15.4 Functions 629
Writing Functions 629
Returning Values 631
Comparing Strings 632
Functions in Files 633
15.5 Arrays 635
15.6 Signals 636
Signal Types 636
Response to Signals 637
trap Command 638
15.7 Built-in Commands 639
Sleep Command 640
Dot Command 641
15.8 Scripting Techniques 641
Reading Strings 641
User Interaction 642
Parsing Options 644
Parsing Pathnames 648
Opening and Closing Files 651
15.9 Shell Environment and
Script 655
15.10 Script Examples 656
Calculate 656
Reverse 658
Add Column 659
15.11 Key Terms 661
15.12 Tips 661
15.13 Commands 662
15.14 Summary 663
15.15 Practice Set 664
Review Questions 664
Exercises 665
15.16 Lab Sessions 666
" t ;' ■ C i
16.1 C Shell Features .671
C Shell Sessions 671
Standard Streams 671
Redirection 671
Pipes 672
tee Command 672
Combining Commands 673
Command-Line Editing 673
Quotes 673
Command Substitution 673
Job Control 674
Aliases in the C Shell 674
16.2 Two Special Files 676
Trash File (/dev/null) 676
Terminal File (/dev/tty) 677
16.3 Variables 679
User-Defined Variables 679
Predefined Variables 679
Storing Values in Variables 680
Accessing the Value of a Variable 681
Null Variables 681
Unsetting a Variable 682
Storing Filenames 682
Storing File Contents 683
Storing Conunands in a Variable 683
Exporting Variables 684
16.4 Output 686
16.5 Input 688
Reading Line by Line 688
Reading Word by Word 688
16.6 Exit Status of a Command 688
16.7 eval Command 689
16.8 Environmental Variables 690
Handling Environmental Variables 694
16.9 On-Off Variables 695
Handling On-Off Variables 697
16.10 Startup and Shutdown Scripts 697
System Startup Files 698
Personal Startup Files 698
Startup Process 698
Shutdown Files 698
16.11 Command History 699
History File 699
History Command 699
Reexecuting Previous Commands 700
Substitute and Reexecute 701
Using Arguments from Previous
Command 702
History Modifier 702
Pathname Modifier 703
History Command Summary 703
16.12 Command Execution
Scripts 704
Execution Steps 704
Command Execution Example 70S
16.13 Key Terms 706
16.14 Tips 706
16.15 Commands 707
16.16 Summary 707
16.17 Practice Set 709
Review Questions 709
Exercises 710
16.18 Lab Sessions 711
€ SlhieOg 1S S
17.1 Basic Script Concepts 715
Script Components 715
Making Scripts Executable 717
Executing the Script 717
Script Termination (exit Command) 72.1
Arguments and Positional Parameters 722
17.2 Expressions 723
Mathematical Expressions 724
Relational Exjpressioiis 725
File Expressions 726
Logical Expressions 727
i7;3 Decisions: Making Selections 728
if-then-else 728
Multiway Selection 732
17.4 Repetition 736
C Shell Loops 736
17.5 Special Parameters 742
Script Name ($0) 743
Number of Arguments ($#argv) 743
All Parameters ($argv) 743
Special Parameter Summary 744
17.6 Changing Positional Parameters 74
shift Command 746
17.7 Argument Validation 747
Number of Arguments Validation 748
Type of Argument Validation 749
17.8 Debugging Scripts 752
Debug Options Included in the Script 752
Debug Options on the Command Line 753
17.9 Script Examples 756
Copy 756
17.10 Key Terms 758
17.11 Tips 758
17.12 Commands 759
17.13 Summary 760
17.14 Practice Set 761
Review Questions 761
Exercises 761
17.15 Lab Sessions 764
CBiapteif fl B
C SlaelQ
Pr@graflW3maiR!g
18.1 Variable Evaluation 769
• 18.2 String Manipulation 769
Compress Strings 770
Using Other Utilities 771
18.3 Here Document 772
18.4 Signals 773
Signal Types 773
Response to Signals 774
On Interrupt Command 774
18.5 Built-in Commands 775
Sleep Command 776
Source Command 111
18.6 Scripting Techniques 777
Reading Strings 778
User Interaction 778
Parsing Pathnames 779
18.7 Shell Environment and Script 780
18.8 Arrays 781
Creating an Array 782
Parsing Input 783
18.9 Script Examples 784
Simulate find Command 784
General Ledger System 786
Eliminate Duplicates 789
18.10 Key Terms 790
18.11 Tips 790
18.12 Commands 791
18.13 Summary 791
18.14 Practice Set 792
Review Questions 792
Exercises 792
18.15 Lab Sessions 793
0534951597 (pbk. : acidfree)
Operating Systems (computers).
005.2/82 / FOR/U
UNIX and Shell programming : a textbook / Behrouz A. Forouzan and Richard F. Gilberg. - Pacific Grove, CA : Brooks/Cole-Thomson Learning, c2003. - xix, 875 p. : ill. (some col.) ; 24 cm.
Includes index.
1.1 Why UNIX? 3
Portable 3
Multiuser 3
Multitasking 3
Networking 4
Organized File System 4
Device Independence 4
Utilities 4
Services 4
1.2 Computer System 4
Hardware 5
Software 5
The Operating System 6
1.3 The UNIX Environment 6
Personal Environment 6
Time-Sharing Environment 7
Client/Server Environment 7
1.4 UNIX Structure 8
The Kernel 8
The Shell 8
Utilities 9
Applications 10
1.5 Accessing UNIX 10
User ID 10
Passwords 10
Interactive Session 11
1.6 Commands 13
Basic Concepts 13
1.7 Common Commands 15
Date and Time (date) Command 15
Calendar (cal) Command 17
Who's Online (who) Command 18
whoami 20
Change Password (passwd) Command 20
Print Message (echo) Command 21
Online Documentation (man) Conunand 22
Print (Ipr) Command 23
1.8 Other Useful Commands 24
Terminal (tty) Command 24
Clear Screen (clear) Command 25
Set Terminal (stty) Command 25
Record Session (script) Command 27
System Name (uname) Command 28
Calculator (be) Command 29
1.9 Key Terms 32
1.10Tips 32
1. 11 Commands 33
1.12 Summary 34
1.13 Practice Set 35
Review Questions 35
Exercises 36
1.14 Lab Sessions 37
^asoc m 4 i
2.1 Editor Concepts 41
Line Editors 41
Screen Editors 41
2.2 The vi Editor 42
2.3 Modes 42
Command Mode 43
Text Mode 43
Changing Modes 43
2.4 Commands 44
Add Commands 44
Cursor Move Commands 46
Deletion Commands 50
Join Command 50
Scrolling Commands 51
Undo Commands 53
Saving and Exit Commands 54
2.5 Two Practice Sessions 55
2.6 Key Terms 57
2.7 Tips 57
2.8 Commands 57
2.9 Summary 58
2.10 Practice Set 60
Review Questions 60
Exercises 60
2.11 Lab Sessions 62
Fe^e Systems 6S
3.1 Filenames 65
Wildcards 66
3.2 File Types 68
3.3 Regular Files 69
Text Files 69
Binary Files 69
3.4 Directories 70
Special Directories 70
Paths and Pathnames 71
Relative Pathname Abbreviations 72
3.5 File System Implementation 75
File Systems 76
Directory Contents 77
Links 77
3.6 Operations Unique to Directories 80
Locate Directory (pwd) Command 80
List Directory (Is) Command 81
Make Directory (mkdir) Command 86
Change Directory (cd) Command 88
Remove Directory (rmdir) Command 89
3.7 Operations Unique to Regular Files 89
■ Create File 89
Edit File 89
Display File (more) Command 90
Print File 92
3.8 Operations Common to Both 93
Copy (cp) Command 93
Move (mv) Command 100
Rename (mv) Command 102
Link (In) Command 102
Remove (rm) Command 106
3.9 Key Terms 112
3.10 Tips 112
3.11 Commands 113
3.12 Summary 114
3.13 Practice Set 115
Review Questions 115
Exercises 116
3.14 Lab Sessions 119
Chapter 4
Security and
FiSe Perai^ss9©8? ! 11
4.1 Users and Groups 121
Group (groups) Command 121
4.2 Security Levels 122
System Security 122
Permission Codes 123
Checking Permissions 126
4.3 Changing Permissions 126^
Symbolic Codes 127
Octal Codes 128
Option 130
4.4 User Masks 131
Basic Concept 131
User Mask (umask) Command 132
4.5 Changing Ownership and Group 132
Change Ownership (chown) Command 133
Change Group (chgrp) Command 133
4.6KeyTerms 134
4.7 Commands 134
4.8 Tips 135
4.9 Summary 135
4.10 Practice Sets 136
Review Questions 136
Exercises 138
4.11 Lab Sessions 140
SgntiTsdiBfStk&in} to Sii'33S^-i
5.1 UNIX Session 144
Login Shell Verification 145
Current Shell Verification 145
Shell Relationships 145
Logout 146
5.2 Standard Streams 146
5.3 Redirection 147
Redirecting Input 147
Redirecting Output 148
Redirecting Errors 149
5.4 Pipes 151
5.5 tee Command 153
5.6 Command Execution 154
Sequenced Commands 155
Grouped Commands 155
Chained Commands 156
Conditional Commands 156
5.7 Command-Line Editing 156
Command-Line Editing Concept 157
Editor Selection 157
vi Command-Line Editor 157
Using the Conrunand-Line Editor 159
5.8 Quotes 159
Backslash 160
Double Quotes 161
Single Quotes 163
5.9 Command Substitution 164
5.10 Job Control 165
Jobs 165
Foreground and Background Jobs 165
jobsConunand 168
Process ID 170
5.11 Aliases 170
Aliases in the Kom and Bash Shells 171
Aliases in the C Shell 174
Alias Summary 176
5.12 Variables 176
User-Defined Variables 176
Predefined Variables 177
Storing Data in Variables 177
Accessing a Variable 178
5.13 Predefined Variables 178
Handling Variables 181
5.14 Options 183
Handling Options 184
5.15 Shell/Environment
Customization 185
Temporary Customization 185
Permanent Customization 185
Summary 187
5.16 Key Terms 188
5.17 Tips 188
5.18 Commands 189
5.19 Summary 191
5.20 Practice Set K92
Review Questions 192
Exercises 193
5.21 Lab Sessions 197
COnapteif 6
FiSteE's f!
6.1 Filters and Pipes 202
6.2 Concatenating Files 202
Catenate (cat) Command 202
cat Options 205
6.3 Display Beginning and End
of Files 207
head Command 207
tail Command 208
6.4 Cut and Paste 210
cut Command 210
paste Command 214
6.5 Sorting 217
sort Command 217
Sort by Lines 217
Sdrt by Fields 219
Options 222
Multiple-Pass Sorting 227
6.6 Translating Characters 230
tr Command 230
Simple Translate 230
Nonmatching Translate Strings 231
Delete Characters 231
Squeeze Output 231
Complement 232
6.7 Flies with Duplicate Lines 233
uniqConunand 233
Output Format 234
Skip Leading Fields 236
Skip Leading Characters 236
6.8 Count Characters, Words,
or Lines 237
wc Command 237
6.9 Comparing Flies 238
Compare (cmp) Command 238
Difference (diff) Command 240
Common (conun) Command 243
6.10 Key Terms 244
6.1 i Tips 244
6.12 Commands 245
6.13 Summary 246
6.14 Practice Set 247
Review Questions 247
Exercises 248
4.15 Lab Sessions 252
Ciiapter 1
€©mBiniim^Q€ait3®ins
%%1
7.1 User Communication 257
talk Command 257
write Conunand 260
7.2 Electronic Mail 262
Mail Addresses 262
Mail Mode 265
mail Command 265
Send Mail 265
Read Mode 270
Read Mail Options 275
Mail Files 275
7.3 Remote Access 276
The telnet Concept 276
Connecting to the Remote
Host 278
7.4 File Transfer 279
The ftp Command 279
Establishing ftp Connection 280
Closing an ftp Connection 280
Transferring Files 281
7.5 Key Terms 282
7.6 Commands 283
7.7 Tips 283
7.8 Summary 284
7.9 Practice Set 285
Review Questions 285
Exercises 286
7.10 Lab Sessions 287
CBnaipter ®
vi GX 19 D
8.1 vl Editor 292 ^
Commands 292
Conunand Categories 293
8.2 Local Commands
in vi 293
Insert Text Conunands (i, I) 293
Append Text Comniands (a. A) 293
Newline Conunands (o, O) 294
Replace Text Commands (r, R) 294
Substitute Text Conunands (s, S) 295
* Delete Character
Conunands (x, X) 295
Mark Text Command (m) 296
Change Case Command (~) 296
Put Commands (p, ?) 297
Join Conunand (J) 298
8.3 Range Commands in vi 299
Text Object 299
Text Object Conunands 304
Yank Conunand 306
Range Command Summary 307
8.4 Global Commands in vi 307
Scroll Commands 307
Undo Commands 307
Repeat Command 308
Screen Regeneration Commands 308
Display Document Status Line 308
Save and Exit Commands 309
8.5 Rearrange Text in vi 309
Move Text. 309
Copy Text 309
Named Buffers 310
8.6 ex Editor 311
ex Instruction Format 311
Addresses 312
Commands 316
8.7 Key Terms 320
8.8 Tips 320
8.9 Commands 321
8.10 Summary 323
8.11 Practice Set 324
Review Questions 324
Exercises 325
8.12 Lab Sessions 326
Chaptcir 9
Kegaaiar 33 B
9.1 Atoms 331
Single Character 332
Dot 332
Class 333
Anchors 334
Back References 335
9.2 Operators 335
Sequence 335
Alternation 337
Repetition 337
Group Operator 341
Save 342
9.3 Key Terms 343
9.4 Tips 343
9.5 Summary 344
9.6 Practice Set 344
Review Questions 344
Exercises 345
CSnapte:." 1 ©
giy-ejn)
10.1 Operation 351
grep flowchart 352
grep Operation Example 352
10.2 grep Family 354
grep 355
Fast grep 356
Extended grep 356
10.3 Examples 359
10.4 Searching for File Content 362
Search a Specific Directory 362
Search All Directories in a Path 363
10.5 Key Terms 364
10.6 Tips 364
10.7 Commands 365
10.8 Summary 365
10.9 Practice Set 366
/
Review Questions 366
Exercises 366
10.10 Lab Sessions 368
CBuiapjteir B i
sesi 373
11.1 Scripts 373
Script Formats 374
Instruction Format 374
Comments 374
11.2 Operation 375
11.3 Addresses 377
Single-Line Addresses 378
Set-of-Line Addresses 379
Range Addresses 380
Nested Addresses 381
11.4 Commands 381
Line Number Command 381
Modify Commands 382
Substitute Command (s) 386
Substitute Flags 39!
Transform Command (y) 393
Input and Output Commands 394
File Commands 399
Branch Commands 401
Hold Space Commands 404
Quit 405
11.5 Applications 406
Delete Lines 406
Delete Text 408
11.6 grep and sed 409
Lines That Match a Regular
Expression 409
Lines That Do Not Match a Regular
Expression 410
11.7 Key Terms 411
11.8 Tips 411
11.9 Commands 412
11.10 Summary 413
11.11 Practice Set 414
Review Questions 414
Exercises 416
11.12 Lab Sessions 421
Chapter 12
awk 42S
12.1 Execution 425
12.2 Fields and Records 426
Buffers and Variables 426
Variables 427
12.3 Scripts 428
Initialization Processing
(BEGIN) 428
Body Processing 429
End Processing (END) 429
12.4 Operation 429
12.5 Patterns 431
Simple Patterns 432
Nothing (No Pattern) 436
Range Patterns 436
12.6 Actions 438
Expression Statement 439
Output Statements 440
Decision Statements 444
Control Actions 446
Loops 449
12.7 Associative Arrays 453
Processing Arrays 454
Delete Array Entry 459
12.8 String Functions 459
Length 460
Index 460
Substring 461
Split 463
Substitution 464
Global Substitution 465
Match 466
ToupperandToIower 466
12.9 Mathematical
Functions 467
12.10 User-Defined
Functions 468
12.11 Using System Commands in
awk 469
Using Pipes 469
Using the System Function 471
12.12 Applications 472
Phone List 472
Count Lines and Words 473
Print Line Following a Blank
Line 473
Print Line Before a Blank
Line 474
Merge Files 474
12.13 awk and grep 475
Find the Line That Matches a Regular
Expression 475
Find the Line That Does Not Match a Regular
Expression 476
12.14 sed and awk 477
Print Line Numbers 477
Modify a Line 478
Substitute 479
Transform 479
Input/Output 480
Files 480
Branch 480
Quit 480
12.15 Key Terms 481
12.16 Tips 481
12.17 Commands 482
12.18 Summary 483
12.19 Practice Set 484
Review Questions 484
Exercises 486
12.20 Lab Sessions 488
Ctepter 13
13.1 Kom Shell Features 499
Kom Shell Sessions 499
Standard Streams 499
Redirection 499
Pipes 500
tee Command 500
Combining Commands 501
Command-Line Editing 501
Quotes 501
Conunand Substitution 501
Job Control 501
Aliases 502
13.2 Two Special Files 502
Trash File (/dev/null) 502
Terminal File (/dev/tty) 503
13.3 Variables 504
User-Defined Variables 504
Predefined Variables 505
Storing Values in Variables 505
Accessing the Value of a Variable 506
Null Variables 507
Unsetting a Variable 508
Storing Filenames 508
Storing File Contents 508
Storing Commands in a Variable 509
Read-Only Variables 509
Exporting Variables 510
Variable Attribute: The typeset
Conunand 512
13.4 Output 514
13.5 Input 516
Reading Word by Word 517
Reading Line by Line 517
Reading from a File 518
13.6 Exit Status of a Command 518
13.7 eval Command 519
13.8 Environmental Variables 521
Change Directory Path (CDPATH) 522
ffistory File Path (HISTFILE) 522
Home Path (HOME) 523
Login Name (LOGNAME) 523
Mailbox Pathname (MAIL) 523
Mail Check Interval (MAILCHECK) -§§4
Incoming Mail Paths (MAILPATH) 524
Directory Search Paths (PATH) 524
Primary Prompt (PSI) 524
Secondary Prompt (PS2) 526
Third Prompt (PS3) 526
Fourth Prompt (PS4) 526
User Input Default Variable (REPLY) 526
Login Shell Path (SHELL) 527
Terminal Description (TERM) 527
Handling Environmental Variables 527
13.9 Options 528
Export All (allexport) 528
Command-Line Editor (emacs and vi) 528
Ignore End-of-File (ignoreeof) 529
No Clobber in Redirection (noclobber) 529
No Execute (noexec) 529
No Global (noglob) 529
Verbosity (verbose) 529
Execute Trace (xtrace) 530
Handling Options 530
13.10 Startup Scripts 530
System Profile File 530
Personal Profile File 531
Environment File 531
Startup Process 532
13.11 Command History 532
History File 532
History Command 533
Redo Command (r) 535
Substitution in Redo Command 536
13.12 Command Execution
Process 536
Execution Steps 536
Command Execution Example 537
13.13 Key Terms 537
13.14 Tips 538
13. f 5 Commands 539
13.16 Summary 540
13.17 Practice Set 541
Review Questions 541
Exercises 542
13.18 Lab Sessions 544
CilDapteir 04
toirra SMIl
14.1 Basic Script Concepts 547
Script Components 547
Making Scripts Executable 549
Executing the Script 549
Script Termination (exit Command) 553
Arguments and Positional Parameters 554
14.2 Expressions 555
Mathematical Expressions 556
' Relational Expressions 557
File Expressions 559
Logical Expressions 560
Expression Type Summary 562
14.3 Decisions: Making Selections 562
if-then-else 562
Multiway Selection 567
14.4 Repetition 571
Command-Controlled and List-Controlled
Loops 571
Background Loops 580
Loop Redirection 580
14.5 Special Parameters and
Variables 585
Special Parameters 585
Special Variables 588
Special Parameter and Variable
Summary 588
14.6 Changing Positional
Parameters 589
shift Command 591
14.7 Argument Validation 593
Number of Arguments Validation 593
Type of Argument Validation 594
14.8 Debugging Scripts 597
Debug Options Included in the Script 597
Debug Options on the Command Line 598
14.9 Script Examples 601
Cat 601
Copy 603
14.10 Key Terms 604
14.11 Tips 605
14.12 Commands 605
14.13 Summary 607
14.14 Practice Set 608
Review Questions 608
Exercises 609
14.15 Lab Sessions 613
C&napiseir IS
$3^eSi
P'rfSgrammoBig 6 8 7
15.1 Variable Evaluation and
Substitution 617
Variabje Evaluation 617
Variable Substitution 618
15.2 String Manipulation 622
Compress Strings 622
String L.ength 623
Locating a Substring in a
String 624
Extraa Substnng 625
Stripping Strings 626
Using Other Utilities 627
15.3 Here Document 628
15.4 Functions 629
Writing Functions 629
Returning Values 631
Comparing Strings 632
Functions in Files 633
15.5 Arrays 635
15.6 Signals 636
Signal Types 636
Response to Signals 637
trap Command 638
15.7 Built-in Commands 639
Sleep Command 640
Dot Command 641
15.8 Scripting Techniques 641
Reading Strings 641
User Interaction 642
Parsing Options 644
Parsing Pathnames 648
Opening and Closing Files 651
15.9 Shell Environment and
Script 655
15.10 Script Examples 656
Calculate 656
Reverse 658
Add Column 659
15.11 Key Terms 661
15.12 Tips 661
15.13 Commands 662
15.14 Summary 663
15.15 Practice Set 664
Review Questions 664
Exercises 665
15.16 Lab Sessions 666
" t ;' ■ C i
16.1 C Shell Features .671
C Shell Sessions 671
Standard Streams 671
Redirection 671
Pipes 672
tee Command 672
Combining Commands 673
Command-Line Editing 673
Quotes 673
Command Substitution 673
Job Control 674
Aliases in the C Shell 674
16.2 Two Special Files 676
Trash File (/dev/null) 676
Terminal File (/dev/tty) 677
16.3 Variables 679
User-Defined Variables 679
Predefined Variables 679
Storing Values in Variables 680
Accessing the Value of a Variable 681
Null Variables 681
Unsetting a Variable 682
Storing Filenames 682
Storing File Contents 683
Storing Conunands in a Variable 683
Exporting Variables 684
16.4 Output 686
16.5 Input 688
Reading Line by Line 688
Reading Word by Word 688
16.6 Exit Status of a Command 688
16.7 eval Command 689
16.8 Environmental Variables 690
Handling Environmental Variables 694
16.9 On-Off Variables 695
Handling On-Off Variables 697
16.10 Startup and Shutdown Scripts 697
System Startup Files 698
Personal Startup Files 698
Startup Process 698
Shutdown Files 698
16.11 Command History 699
History File 699
History Command 699
Reexecuting Previous Commands 700
Substitute and Reexecute 701
Using Arguments from Previous
Command 702
History Modifier 702
Pathname Modifier 703
History Command Summary 703
16.12 Command Execution
Scripts 704
Execution Steps 704
Command Execution Example 70S
16.13 Key Terms 706
16.14 Tips 706
16.15 Commands 707
16.16 Summary 707
16.17 Practice Set 709
Review Questions 709
Exercises 710
16.18 Lab Sessions 711
€ SlhieOg 1S S
17.1 Basic Script Concepts 715
Script Components 715
Making Scripts Executable 717
Executing the Script 717
Script Termination (exit Command) 72.1
Arguments and Positional Parameters 722
17.2 Expressions 723
Mathematical Expressions 724
Relational Exjpressioiis 725
File Expressions 726
Logical Expressions 727
i7;3 Decisions: Making Selections 728
if-then-else 728
Multiway Selection 732
17.4 Repetition 736
C Shell Loops 736
17.5 Special Parameters 742
Script Name ($0) 743
Number of Arguments ($#argv) 743
All Parameters ($argv) 743
Special Parameter Summary 744
17.6 Changing Positional Parameters 74
shift Command 746
17.7 Argument Validation 747
Number of Arguments Validation 748
Type of Argument Validation 749
17.8 Debugging Scripts 752
Debug Options Included in the Script 752
Debug Options on the Command Line 753
17.9 Script Examples 756
Copy 756
17.10 Key Terms 758
17.11 Tips 758
17.12 Commands 759
17.13 Summary 760
17.14 Practice Set 761
Review Questions 761
Exercises 761
17.15 Lab Sessions 764
CBiapteif fl B
C SlaelQ
Pr@graflW3maiR!g
18.1 Variable Evaluation 769
• 18.2 String Manipulation 769
Compress Strings 770
Using Other Utilities 771
18.3 Here Document 772
18.4 Signals 773
Signal Types 773
Response to Signals 774
On Interrupt Command 774
18.5 Built-in Commands 775
Sleep Command 776
Source Command 111
18.6 Scripting Techniques 777
Reading Strings 778
User Interaction 778
Parsing Pathnames 779
18.7 Shell Environment and Script 780
18.8 Arrays 781
Creating an Array 782
Parsing Input 783
18.9 Script Examples 784
Simulate find Command 784
General Ledger System 786
Eliminate Duplicates 789
18.10 Key Terms 790
18.11 Tips 790
18.12 Commands 791
18.13 Summary 791
18.14 Practice Set 792
Review Questions 792
Exercises 792
18.15 Lab Sessions 793
0534951597 (pbk. : acidfree)
Operating Systems (computers).
005.2/82 / FOR/U