UNIX Shell Programming

Front Cover
Sams Publishing, 2003 - Computers - 437 pages

Unix Shell Programming is a tutorial aimed at helping Unix and Linux users get optimal performance out of their operating out of their operating system. It shows them how to take control of their systems and work efficiently by harnessing the power of the shell to solve common problems. The reader learns everything he or she needs to know to customize the way a Unix system responds.

The vast majority of Unix users utilize the Korn shell or some variant of the Bourne shell, such as bash. Three are covered in the third edition of Unix Shell Programming. It begins with a generalized tutorial of Unix and tools and then moves into detailed coverage of shell programming.

Topics covered include: regular expressions, the kernel and the utilities, command files, parameters, manipulating text filters, understanding and debugging shell scripts, creating and utilizing variables, tools, processes, and customizing the shell.

 

Selected pages

Contents

A Quick Review of the Basics
5
Working with Files
6
The is Command
7
The we Command
8
The cp Command
9
The rm Command
10
The Home Directory and Pathnames
11
The pwd Command
12
Special echo Escape Characters
212
A Final Version of mycp
214
A MenuDriven Phone Program
219
The Variable and Temporary Files
224
The Exit Status from read
225
The printf Command
228
Exercises
233
Your Environment
235

The cd Command
13
More on the is Command
16
The mkdir Command
18
Moving Files Between Directories
19
The in Command
20
The rmdir Command
24
Matching Single Characters
26
Standard InputOutput and IO Redirection
28
Output Redirection
30
Input Redirection
32
Pipes
33
Filters
35
More on Commands
36
The ps Command
37
Command Summary
38
What Is the Shell?
41
The Login Shell
42
Typing Commands to the Shell
45
The Shells Responsibilities
46
Variable and Filename Substitution
48
IO Redirection
49
Pipeline Hookup
51
Interpreted Programming Language
52
Tools of the Trade
53
The Period
54
The Caret
55
The Construct
57
The Asterisk
59
cut
67
The d and f Options
69
paste
72
The d Option
73
The s Option
74
The n Option
76
Deleting Lines
77
tr
78
The s Option
81
The d Option
82
grep
83
Regular Expressions and grep
86
The v Option
87
The l Option
88
The n Option
89
The u Option
90
The n Option
91
Skipping Fields
92
Other Options
93
uniq
94
The d Option
95
Other Options
96
Exercises
97
And Away We Go
99
Comments
102
Variables
103
Displaying the Values of Variables
104
The Null Value
107
Filename Substitution and Variables
108
The variable Construct
110
Exercises
112
Can I Quote You on That?
115
The Double Quote
119
The Backslash
121
Using the Backslash for Continuing Lines
122
The Backslash Inside Double Quotes
123
Command Substitution
124
The Construct
125
The expr Command
129
Exercises
131
Passing Arguments
133
The Variable
134
The Variable
135
A Program to Look Up Someone in the Phone Book
136
A Program to Add Someone to the Phone Book
138
A Program to Remove Someone from the Phone Book
139
Sn
141
Exercises
143
Decisions Decisions
145
The ? Variable
146
The test Command
149
String Operators
150
An Alternative Format for test
154
Integer Operators
155
File Operators
157
The Logical Negation Operator
158
Parentheses
159
The else Construct
160
The exit Command
162
A Second Look at the rem Program
163
The elif Construct
164
Yet Another Version of rem
167
The case Command
169
Special Pattern Matching Characters
171
The x Option for Debugging Programs
173
Back to the case
175
Exercises
180
Round and Round She Goes
183
The S Variable
187
The for Without the List
188
The while Command
189
The until Command
191
More on Loops
196
Skipping the Remaining Commands in a Loop
198
Executing a Loop in the Background
199
Piping Data Into and Out of a Loop
200
The getopts Command
201
Exercises
205
Reading and Printing Data
209
Subshells
236
Exported Variables
237
export p
241
HOME James
242
Your PATH
243
Your Current Directory
251
CDPATH
252
More on Subshells
253
The Command
254
The exec Command
257
The and Constructs
258
Another Way to Pass Variables to a Subshell
262
The TERM Variable
264
Exercises
265
More on Parameters
267
parameter
268
value
269
parameter?value
270
variable
273
The set Command
274
set with No Arguments
275
Using set to Reassign Positional Parameters
276
The Option
277
Other Options to set
280
The readonly Command
283
The unset Command
284
Loose Ends
287
The wait Command
289
The Variable
290
trap with No Arguments
292
Resetting Traps
293
and
295
Shell Archives
297
Functions
301
Removing a Function Definition
304
The type Command
305
Rolo Revisited
307
rolo
308
add
311
lu
312
display
313
rem
314
change
316
listall
318
Sample Output
319
Exercises
323
Interactive and Nonstandard Shell Features
325
Getting the Right Shell
326
CommandLine Editing
327
The vi Line Edit Mode
328
Accessing Commands from Your History
330
The Line Edit Mode
332
Accessing Commands from Your History
334
Other Ways to Access Your History
336
The fc Command
337
The r Command
338
Functions
339
Automatically Loaded Functions
340
Integer Types
341
Numbers in Different Bases
342
The alias Command
343
Removing Aliases
346
Job Control
352
Stopped Jobs and the fg and bg Commands
353
The Restricted Shell rsh
355
Miscellaneous Features
357
Order of Search
359
Exercises
360
Shell Summary
363
Comments
364
Positional Parameters
365
Parameter Substitution
366
Command Reentry
367
The fc Command
368
Quoting
370
Tilde Substitution
371
Filename Substitution
372
IO Redirection
373
The Construct
374
Job Control
375
Command Summary
376
The alias Command
377
The case Command
378
The cd Command
379
The continue command
380
The eval Command
381
The exit Command
382
The false Command
383
The fg Command
384
The getopts Command
385
The hash Command
387
The jobs Command
390
The newgrp Command
391
The read Command
392
The return Command
393
The shift Command
395
The test Command
396
The times Command
398
The true Command
399
The umask Command
400
The wait Command
401
The while Command
402
For More Information
403
Books
404
Sams and Que
405
Other Publishers
406
Copyright

Other editions - View all

Common terms and phrases

Bibliographic information