| Introduction |
|
1 | (4) |
|
How This Book Is Organized |
|
|
2 | (1) |
|
Accessing the Free Web Edition |
|
|
3 | (2) |
| 1 A Quick Review of the Basics |
|
5 | (34) |
|
|
|
5 | (1) |
|
Displaying the Date and Time: The date Command |
|
|
5 | (1) |
|
Finding Out Who's Logged In: The who Command |
|
|
5 | (1) |
|
Echoing Characters: The echo Command |
|
|
6 | (1) |
|
|
|
6 | (3) |
|
Listing Files: The is Command |
|
|
7 | (1) |
|
Displaying the Contents of a File: The cat Command |
|
|
7 | (1) |
|
Counting the Number of Words in a File: The we Command |
|
|
7 | (1) |
|
|
|
8 | (1) |
|
Making a Copy of a File: The cp Command |
|
|
8 | (1) |
|
Renaming a File: The my Command |
|
|
8 | (1) |
|
Removing a File: The rm Command |
|
|
9 | (1) |
|
|
|
9 | (15) |
|
The Home Directory and Pathnames |
|
|
10 | (2) |
|
Displaying Your Working Directory: The pwd Command |
|
|
12 | (1) |
|
Changing Directories: The cd Command |
|
|
12 | (3) |
|
|
|
15 | (2) |
|
Creating a Directory: The mkdir Command |
|
|
17 | (1) |
|
Copying a File from One Directory to Another |
|
|
18 | (1) |
|
Moving Files Between Directories |
|
|
19 | (1) |
|
Linking Files: The in Command |
|
|
20 | (3) |
|
Removing a Directory: The rmdir Command |
|
|
23 | (1) |
|
|
|
24 | (3) |
|
|
|
24 | (1) |
|
Matching Single Characters |
|
|
25 | (2) |
|
|
|
27 | (1) |
|
|
|
27 | (1) |
|
|
|
28 | (1) |
|
Standard Input/Output, and I/O Redirection |
|
|
28 | (5) |
|
Standard Input and Standard Output |
|
|
28 | (2) |
|
|
|
30 | (2) |
|
|
|
32 | (1) |
|
|
|
33 | (2) |
|
|
|
35 | (1) |
|
|
|
35 | (1) |
|
|
|
36 | (1) |
|
Typing More Than One Command on a Line |
|
|
36 | (1) |
|
Sending a Command to the Background |
|
|
36 | (1) |
|
|
|
37 | (1) |
|
|
|
37 | (2) |
| 2 What Is the Shell? |
|
39 | (12) |
|
The Kernel and the Utilities |
|
|
39 | (1) |
|
|
|
40 | (3) |
|
Typing Commands to the Shell |
|
|
43 | (1) |
|
The Shell's Responsibilities |
|
|
44 | (7) |
|
|
|
45 | (2) |
|
Variable and Filename Substitution |
|
|
47 | (1) |
|
|
|
48 | (1) |
|
|
|
49 | (1) |
|
|
|
49 | (1) |
|
Interpreted Programming Language |
|
|
50 | (1) |
| 3 Tools of the Trade |
|
51 | (42) |
|
|
|
51 | (13) |
|
Matching Any Character: The Period (.) |
|
|
51 | (2) |
|
Matching the Beginning of the Line: The Caret (^) |
|
|
53 | (1) |
|
Matching the End of the Line: The Dollar Sign $ |
|
|
53 | (2) |
|
Matching a Character Set: The [ ...] Construct |
|
|
55 | (2) |
|
Matching Zero or More Characters: The Asterisk (*) |
|
|
57 | (2) |
|
Matching a Precise Number of Subpatterns: \{...\} |
|
|
59 | (2) |
|
Saving Matched Characters: \{...\} |
|
|
61 | (3) |
|
|
|
64 | (4) |
|
|
|
66 | (2) |
|
|
|
68 | (2) |
|
|
|
69 | (1) |
|
|
|
70 | (1) |
|
|
|
70 | (4) |
|
|
|
72 | (1) |
|
|
|
73 | (1) |
|
|
|
74 | (4) |
|
|
|
76 | (1) |
|
|
|
77 | (1) |
|
|
|
78 | (6) |
|
Regular Expressions and grep |
|
|
81 | (1) |
|
|
|
82 | (1) |
|
|
|
82 | (1) |
|
|
|
83 | (1) |
|
|
|
84 | (4) |
|
|
|
84 | (1) |
|
|
|
85 | (1) |
|
|
|
85 | (1) |
|
|
|
86 | (1) |
|
|
|
87 | (1) |
|
|
|
87 | (1) |
|
|
|
88 | (1) |
|
|
|
88 | (5) |
|
|
|
89 | (1) |
|
|
|
90 | (3) |
| 4 And Away We Go |
|
93 | (12) |
|
|
|
93 | (4) |
|
|
|
96 | (1) |
|
|
|
97 | (6) |
|
Displaying the Values of Variables |
|
|
98 | (2) |
|
Undefined Variables Have the Null Value |
|
|
100 | (1) |
|
Filename Substitution and Variables |
|
|
101 | (1) |
|
The ${variable} Construct |
|
|
102 | (1) |
|
Built-in Integer Arithmetic |
|
|
103 | (2) |
| 5 Can I Quote You on That? |
|
105 | (16) |
|
|
|
105 | (4) |
|
|
|
109 | (2) |
|
|
|
111 | (3) |
|
Using the Backslash for Continuing Lines |
|
|
112 | (1) |
|
The Backslash Inside Double Quotes |
|
|
112 | (2) |
|
|
|
114 | (7) |
|
|
|
114 | (1) |
|
|
|
115 | (4) |
|
|
|
119 | (2) |
| 6 Passing Arguments |
|
121 | (10) |
|
|
|
122 | (1) |
|
|
|
123 | (1) |
|
A Program to Look Up Someone in the Phone Book |
|
|
124 | (1) |
|
A Program to Add Someone to the Phone Book |
|
|
125 | (2) |
|
A Program to Remove Someone from the Phone Book |
|
|
127 | (1) |
|
|
|
128 | (1) |
|
|
|
128 | (3) |
| 7 Decisions, Decisions |
|
131 | (32) |
|
|
|
131 | (4) |
|
|
|
132 | (3) |
|
|
|
135 | (10) |
|
|
|
135 | (4) |
|
An Alternative Format for test |
|
|
139 | (1) |
|
|
|
140 | (2) |
|
|
|
142 | (1) |
|
The Logical Negation Operator ! |
|
|
143 | (1) |
|
The Logical AND Operator -a |
|
|
143 | (1) |
|
|
|
144 | (1) |
|
The Logical OR Operator -o |
|
|
144 | (1) |
|
|
|
145 | (2) |
|
|
|
147 | (1) |
|
A Second Look at the rem Program |
|
|
147 | (1) |
|
|
|
148 | (5) |
|
Yet Another Version of rem |
|
|
151 | (2) |
|
|
|
153 | (7) |
|
Special Pattern-Matching Characters |
|
|
155 | (2) |
|
The -x Option for Debugging Programs |
|
|
157 | (2) |
|
|
|
159 | (1) |
|
|
|
160 | (1) |
|
|
|
161 | (2) |
| 8 'Round and 'Round She Goes |
|
163 | (22) |
|
|
|
163 | (5) |
|
|
|
166 | (1) |
|
|
|
167 | (1) |
|
|
|
168 | (2) |
|
|
|
170 | (4) |
|
|
|
174 | (6) |
|
|
|
174 | (2) |
|
Skipping the Remaining Commands in a Loop |
|
|
176 | (1) |
|
Executing a Loop in the Background |
|
|
177 | (1) |
|
I/O Redirection on a Loop |
|
|
177 | (1) |
|
Piping Data into and out of a Loop |
|
|
178 | (1) |
|
Typing a Loop on One Line |
|
|
179 | (1) |
|
|
|
180 | (5) |
| 9 Reading and Printing Data |
|
185 | (24) |
|
|
|
185 | (17) |
|
|
|
185 | (2) |
|
Special echo Escape Characters |
|
|
187 | (1) |
|
An Improved Version of mycp |
|
|
188 | (2) |
|
|
|
190 | (3) |
|
A Menu-Driven Phone Program |
|
|
193 | (5) |
|
The $$ Variable and Temporary Files |
|
|
198 | (1) |
|
The Exit Status from read |
|
|
199 | (3) |
|
|
|
202 | (7) |
| 10 Your Environment |
|
209 | (30) |
|
|
|
209 | (2) |
|
|
|
210 | (1) |
|
|
|
211 | (5) |
|
|
|
215 | (1) |
|
|
|
216 | (1) |
|
|
|
217 | (1) |
|
|
|
217 | (8) |
|
|
|
225 | (2) |
|
|
|
226 | (1) |
|
|
|
227 | (8) |
|
|
|
227 | (3) |
|
|
|
230 | (1) |
|
The (...) and {...;} Constructs |
|
|
231 | (3) |
|
Another Way to Pass Variables to a Subshell |
|
|
234 | (1) |
|
|
|
235 | (1) |
|
|
|
236 | (1) |
|
|
|
237 | (2) |
| 11 More on Parameters |
|
239 | (16) |
|
|
|
239 | (6) |
|
|
|
239 | (1) |
|
|
|
240 | (1) |
|
|
|
241 | (1) |
|
|
|
241 | (1) |
|
|
|
242 | (1) |
|
Pattern Matching Constructs |
|
|
242 | (2) |
|
|
|
244 | (1) |
|
|
|
245 | (1) |
|
|
|
246 | (5) |
|
|
|
246 | (1) |
|
|
|
247 | (1) |
|
Using set to Reassign Positional Parameters |
|
|
247 | (1) |
|
|
|
248 | (3) |
|
|
|
251 | (1) |
|
|
|
251 | (3) |
|
|
|
254 | (1) |
|
|
|
254 | (1) |
| 12 Loose Ends |
|
255 | (18) |
|
|
|
255 | (2) |
|
|
|
257 | (1) |
|
|
|
257 | (1) |
|
|
|
258 | (3) |
|
|
|
259 | (1) |
|
|
|
260 | (1) |
|
|
|
261 | (1) |
|
|
|
261 | (7) |
|
|
|
262 | (1) |
|
In-line Input Redirection |
|
|
262 | (2) |
|
|
|
264 | (4) |
|
|
|
268 | (3) |
|
Removing a Function Definition |
|
|
271 | (1) |
|
|
|
271 | (1) |
|
|
|
271 | (2) |
| 13 Rolo Revisited |
|
273 | (16) |
|
Data Formatting Considerations |
|
|
273 | (1) |
|
|
|
274 | (3) |
|
|
|
277 | (1) |
|
|
|
278 | (1) |
|
|
|
278 | (2) |
|
|
|
280 | (1) |
|
|
|
281 | (2) |
|
|
|
283 | (1) |
|
|
|
284 | (5) |
| 14 Interactive and Nonstandard Shell Features |
|
289 | (32) |
|
|
|
289 | (1) |
|
|
|
290 | (1) |
|
|
|
291 | (1) |
|
|
|
292 | (1) |
|
|
|
292 | (4) |
|
Accessing Commands from Your History |
|
|
294 | (2) |
|
|
|
296 | (4) |
|
Accessing Commands from Your History |
|
|
298 | (2) |
|
Other Ways to Access Your History |
|
|
300 | (3) |
|
|
|
300 | (1) |
|
|
|
301 | (1) |
|
|
|
301 | (2) |
|
|
|
303 | (1) |
|
|
|
303 | (1) |
|
Automatically Loaded Functions |
|
|
303 | (1) |
|
|
|
303 | (4) |
|
|
|
304 | (1) |
|
Numbers in Different Bases |
|
|
305 | (2) |
|
|
|
307 | (2) |
|
|
|
309 | (1) |
|
|
|
309 | (6) |
|
|
|
315 | (2) |
|
Stopped Jobs and the fg and bg Commands |
|
|
316 | (1) |
|
|
|
317 | (2) |
|
Other Features of the cd Command |
|
|
317 | (1) |
|
|
|
318 | (1) |
|
|
|
319 | (1) |
|
|
|
319 | (2) |
| A Shell Summary |
|
321 | (38) |
|
|
|
321 | (1) |
|
|
|
321 | (1) |
|
|
|
322 | (1) |
|
|
|
322 | (4) |
|
|
|
322 | (1) |
|
|
|
322 | (1) |
|
|
|
323 | (1) |
|
|
|
324 | (2) |
|
|
|
326 | (3) |
|
|
|
326 | (1) |
|
|
|
326 | (3) |
|
|
|
329 | (2) |
|
|
|
329 | (1) |
|
|
|
330 | (1) |
|
|
|
331 | (1) |
|
|
|
331 | (1) |
|
Exported Variables and Subshell Execution |
|
|
332 | (1) |
|
|
|
332 | (1) |
|
|
|
332 | (1) |
|
|
|
333 | (1) |
|
|
|
333 | (1) |
|
|
|
333 | (1) |
|
|
|
333 | (1) |
|
|
|
334 | (1) |
|
|
|
334 | (25) |
|
|
|
334 | (1) |
|
|
|
334 | (1) |
|
|
|
335 | (1) |
|
|
|
335 | (1) |
|
|
|
336 | (1) |
|
|
|
336 | (1) |
|
|
|
337 | (1) |
|
|
|
338 | (1) |
|
|
|
338 | (1) |
|
|
|
339 | (1) |
|
|
|
339 | (1) |
|
|
|
340 | (1) |
|
|
|
340 | (1) |
|
|
|
341 | (1) |
|
|
|
341 | (1) |
|
|
|
342 | (1) |
|
|
|
342 | (1) |
|
|
|
343 | (1) |
|
|
|
344 | (1) |
|
|
|
344 | (3) |
|
|
|
347 | (1) |
|
|
|
347 | (1) |
|
|
|
347 | (1) |
|
|
|
348 | (1) |
|
|
|
348 | (1) |
|
|
|
349 | (1) |
|
|
|
349 | (1) |
|
|
|
350 | (2) |
|
|
|
352 | (1) |
|
|
|
352 | (2) |
|
|
|
354 | (1) |
|
|
|
355 | (1) |
|
|
|
356 | (1) |
|
|
|
356 | (1) |
|
|
|
356 | (1) |
|
|
|
356 | (1) |
|
|
|
357 | (1) |
|
|
|
357 | (1) |
|
|
|
358 | (1) |
|
|
|
358 | (1) |
| B For More Information |
|
359 | (4) |
|
|
|
359 | (1) |
|
|
|
360 | (1) |
|
|
|
360 | (3) |
|
|
|
360 | (1) |
|
|
|
361 | (2) |
| Index |
|
363 | |