search for books and compare prices
Tables of Contents for Unix Power Tools
Chapter/Section Title
Page #
Page Count
Preface
XXXV
 
Chapter 1: Introduction
1
40
1.01 What's Special About UNIX?
1
1
1.02 Who Listens to What You Type?
2
2
1.03 Programs Are Designed to Work Together
4
1
1.04 Using Pipes to Create a New Tool
4
2
1.05 Anyone Can Program the Shell
6
1
1.06 Power Tools for Editing
7
1
1.07 Power Grows on You
8
1
1.08 There Are Many Shells
9
2
1.09 Which Shell Am I Running?
11
1
1.10 Internal and External Commands
11
1
1.11 How the Shell Executes Other Commands
12
1
1.12 What Makes a Shell Script?
13
1
1.13 Why Fundamentals Are Important
13
1
1.14 The Kernel and Daemons
14
2
1.15 Filenames
16
1
1.16 Wildcards
17
2
1.17 Filename Extensions
19
1
1.18 Who Handles Wildcards?
20
1
1.19 The Tree Structure of the Filesystem
21
2
1.20 Your Home Directory
23
1
1.21 Making Pathnames
24
2
1.22 How UNIX Keeps Track of Files: Inodes
26
1
1.23 File Access Permissions
27
3
1.24 The Superuser (Root)
30
1
1.25 Access to Directories
31
1
1.26 What a Multiuser System Can Do for You
31
1
1.27 How Background Processing Works
32
1
1.28 Some Gotchas With Background Processing
33
1
1.29 When Is a File Not a File?
34
1
1.30 Redirecting Input and Output
35
1
1.31 The X Window System
35
1
1.32 One Big Hole
36
1
1.33 UNIX Networking and Communications
36
2
1.34 What's Wrong with UNIX
38
3
Part One: Making Yourself at Home
41
76
Chapter 2: Logging In
41
18
2.01 Customizing the Shell
41
1
2.02 Shell Setup Files--Which, Where, and Why
41
2
2.03 What Goes in Shell Setup Files?
43
1
2.04 Tip for Changing Account Setup: Keep a Shell Ready
44
1
2.05 Tips for Speeding up Slow Logins
44
3
2.06 Use Absolute Pathnames in Shell Setup Files
47
1
2.07 C Shell Setup Files Aren't Read When You Want Them to Be?
47
1
2.08 Identifying Login Shells
48
1
2.09 Speeding Up Your C Shell with set prompt Test
49
1
2.10 Gotchas in set prompt Test
49
2
2.11 Faster ksh and bash Startup with XXX-Test
51
1
2.12 Automatic Setups for Different Terminals
51
2
2.13 A.cshrc.XXXHOST File for Per Host Setup
53
1
2.14 motd.diff: Show New Lines in Login Messages
54
1
2.15 Unclutter Logins: Show Login Messages Just Once
55
1
2.16 Approved Shells: Using Unapproved Login Shell
56
3
Chapter 3: Logging Out
59
6
3.01 Running Commands When You Log Out
59
1
3.02 Running Commands at Bourne/Korn Shell Logout
60
1
3.03 Electronic Fortune Cookies
60
1
3.04 Automatic File Cleanup
61
1
3.05 Stop Accidental C Shell Logouts
61
1
3.06 Stop Accidental Bourne Shell Logouts
62
1
3.07 Detaching a Session with Screen
63
1
3.08 What try Am I On?
63
2
Chapter 4: Organizing Your Home Directory
65
8
4.01 What? Me, Organized?
65
1
4.02 A bin Directory for Your Programs and Scripts
66
1
4.03 Organizing Nonexecutable Scripts
66
1
4.04 Directories for Emacs Hacks
67
1
4.05 Private (Personal) Directories
67
1
4.06 Naming Files
67
1
4.07 Make More Directories!
68
1
4.08 Making Directories Made Easier
69
1
4.09 Setting Up vi with the .exrc File
70
1
4.10 Find All Command Versions with whereiz
71
2
Chapter 5: Setting Up Your Terminal
73
16
5.01 There's a Lot to Know About Terminals
73
1
5.02 The Idea of a Terminal Database
73
2
5.03 Setting the Terminal Type When You Log In
75
2
5.04 Setting the TERMCAP Variable with tset
77
1
5.05 Querying Your Terminal Type: qterm
78
2
5.06 Checklist: Terminal Hangs When I Log In
80
1
5.07 What termcap and terminfo Do and Don't Control
81
1
5.08 Terminal Escape Sequences
82
1
5.09 Setting Your Erase, Kill, and Interrupt Characters
83
1
5.10 Finding What Terminal Names You Can Use
84
2
5.11 Initializing the Terminal with tset
86
1
5.12 Initializing the Terminal with tput
87
2
Chapter 6: Shell and Environment Variables
89
12
6.01 What Environment Variables Are Good For
89
2
6.02 Parent-Child Relationships
91
1
6.03 Predefined Environment Variables
91
2
6.04 The PATH Environment Variables
93
2
6.05 PATH and path
95
1
6.06 The TZ Environment Variable
95
1
6.07 What Time Is It in Japan?
96
1
6.08 Shell Variables
97
1
6.09 Special C Shell Variables
98
2
6.10 Running a Command with a Different Environment
100
1
Chapter 7: Setting Your Shell Prompt
101
16
7.01 Why Change Your Prompt?
101
1
7.02 Basics of Setting the Prompt
101
1
7.03 C Shell Prompt Causes Problems in vi, rsh, etc.
102
1
7.04 Faster Prompt Setting with Built-Ins
103
1
7.05 Multiline Shell Prompts
104
1
7.06 Session Information in Your Terminal's Status Line
105
1
7.07 A "Menu Prompt" for Native Users
106
1
7.08 Highlighting in Shell Prompts
107
1
7.09 Show Subshell Level with $SHLVL
108
2
7.10 What Good Is a Blank Shell Prompt?
110
1
7.11 dirs in Your Prompt: Better than $cwd
111
1
7.12 External Commands Send Signals to Set Variables
112
1
7.13 Pre-Prompt Commands in bash
113
4
Part Two: Let the Computer Do the Dirty Work
117
120
Chapter 8: How the Shell Interprets What You Type
117
30
8.01 What the Shell Does
117
1
8.02 Introduction to bash
118
1
8.03 Introduction to tcsh
119
1
8.04 Command Evalution and Accidentally Overwriting Files
120
1
8.05 Command-Line Evaluation
121
2
8.06 Output Command-Line Arguments
123
2
8.07 Setting Your Search Path
125
2
8.08 A Directory for Commands You Shouldn't Run
127
1
8.09 Wildcards Inside of Aliases
128
1
8.10 eval: When You Need Another Chance
129
1
8.11 Which One Will bash Use?
130
1
8.12 Which One Will the C Shell Use?
131
2
8.13 Is It "2 greater than & 1 greater than file" or "greater than file 2 greater than & one"? Why?
133
1
8.14 Bourne Shell Quoting
133
5
8.15 Differences Between Bourne and C Shell Quoting
138
1
8.16 Quoting Handles Special Characters in Filenames
139
1
8.17 Verbose and echo Variables Show Quoting
140
1
8.18 Here Documents
140
1
8.19 "Special" Characters and Operators
141
4
8.20 How Many Backslashes?
145
2
Chapter 9: Saving Time on the Command Line
147
33
9.01 What's Special About the UNIX Command Line
147
1
9.02 Fix a Line Faster with Line-Kill and Word-Erase
148
1
9.03 Reprinting Your Command Line with CTRL-r
149
1
9.04 Use Wildcards to Create Files?
149
1
9.05 Build Strings with {}
150
1
9.06 String Editing (Colon) Operators
151
2
9.07 String Editing in ksh and bash
153
1
9.08 Filename Completion: Faster Filename Typing
154
1
9.09 Don't Match Useless Files in Filename Completion
155
1
9.10 Filename Completion Isn't Always the Answer
156
1
9.11 Repeating a Command with a foreach Loop
156
2
9.12 The Bourne Shell for Loop
158
1
9.13 Multiline Commands, Secondary Prompts
159
1
9.14 Using Here Documents for Form Letters, etc.
160
1
9.15 Throwaway Scripts for Complicated Commands
161
1
9.16 Command Substitution
161
2
9.17 Handling Lots of Text with Temporary Files
163
1
9.18 Process Substitution
164
2
9.19 For the Impatient: Type-Ahead
166
2
9.20 Too Many Files for the Command Line
168
1
9.21 Handle Too-Long Command Lines with X args
169
2
9.22 xargs: Problems with Spaces and Newlines
171
1
9.23 Workaround for "Arguments Too Long" Error
172
1
9.24 Get File List by Editing Output of Is-1, grep, etc.
173
2
9.25 The C Shell repeat Command
175
1
9.26 Expect
176
4
Chapter 10: Aliases
180
12
10.01 Creating Custom Commands
180
1
10.02 Aliases for Common Commands
180
3
10.03 C Shell Aliases with Command-Line Arguments
183
2
10.04 Aliases in ksh and bash
185
1
10.05 Sourceable Scripts
185
2
10.06 Avoiding C Shell Alias Loops
187
1
10.07 How to Put if-then-else in a C Shell Alias
188
1
10.08 Fix Quoting in csh Aliases with makealias and quote
189
1
10.09 Shell Functions
189
1
10.10 Simulated Bourne Shell Functions and Aliases
190
2
Chapter 11: The Lessons of History
192
19
11.01 The Lessons of History
192
1
11.02 History in a Nutshell
193
1
11.03 My Favorite Is !$
194
1
11.04 My Favorite Is !:n*
194
1
11.05 My Favorite Is ^^
195
1
11.06 Using !$ for Safety with Wildcards
196
1
11.07 History Substitutions
196
5
11.08 Repeating a Cycle of Commands
201
1
11.09 Running a Series of Commands on a File
201
1
11.10 Check Your History First with: P
202
1
11.11 Picking Up Where You Left Off
203
2
11.12 Pass History to Another Shell
205
1
11.13 Shell Command-Line Editing
206
1
11.14 More Ways to Do Interactive History Editing
207
2
11.15 Changing C Shell History Characters with histchars
209
1
11.16 Instead of Changing History Characters
210
1
Chapter 12: Job Control
211
9
12.01 Job Control: Work Faster, Stop Runaway Jobs
211
2
12.02 Other Ways to Refer to Jobs
213
1
12.03 The "Current Job" Isn't Always What You Expect
214
1
12.04 Job Control and Autowrite: Real Time Savers!
215
1
12.05 System Overloaded? Try Stopping Some Jobs
215
1
12.06 Notification When Jobs Change State
216
1
12.07 Stop Background Output with stty tostop
217
1
12.08 Job Control in a Nutshell
217
1
12.09 Running Multiple Shell Sessions with screen
218
2
Chapter 13: Redirecting Input and Output
220
17
13.01 Using Standard Input and Output
220
3
13.02 One Argument with a cat Isn't Enough
223
1
13.03 Send (only) Standard Error Down a Pipe
223
1
13.04 Problems Piping to a Pager
224
1
13.05 Redirection in C Shell; Capture Errors, Too?
225
1
13.06 Safe I/O Redirection with noclobber
226
1
13.07 The O Subshell Operators
227
1
13.08 Using {list} to Group Bourne Shell Commands
228
1
13.09 Send Output Two or More Places with tee
229
1
13.10 How to tee Several Commands Into One File
229
1
13.11 tpipe--Redirecting stdout to More than One Place
230
1
13.12 Writing to Multiple Terminals for Demonstrations
231
1
13.13 The "Filename"-
231
1
13.14 What Can You Do with an Empty File?
232
1
13.15 What to Do with a Full Bit Bucket :-)
233
1
13.16 Store and Show Errors with Logerrs
234
3
Part Three: Working with the Filesystem
237
200
Chapter 14: Moving Around in a Hurry
237
16
14.01 Getting Around the Filesystem
237
1
14.02 Using Relative and Absolute Pathnames
238
2
14.03 What Good Is a Current Directory?
240
1
14.04 How Does UNIX Find Your Current Directory?
241
1
14.05 Saving Time When You Change Directories: cdpath
242
1
14.06 The Shells' pushd and popd Commands
243
2
14.07 Nice Aliases for pushd
245
1
14.08 Quick cds with Aliases
245
1
14.09 cd by Directory Initials
246
1
14.10 Variables Help You Find Directories and Files
247
2
14.11 Finding (Anyone's) Home Directory, Quickly
249
1
14.12 Marking Your Place with a Shell Variable
249
1
14.13 Which Directory Am I in, Really?
250
1
14.14 Automatic Setup When You Enter/Exit a Directory
251
2
Chapter 15: Wildcards
253
10
15.01 File Naming Wildcards
253
1
15.02 Filename Wildcards in a Nutshell
254
2
15.03 Adding {} Operators to Korn (and Bourne) Shells
256
1
15.04 What if a Wildcard Doesn't Match?
256
1
15.05 Matching All "Dot Files" with Wildcards
257
1
15.06 Maybe You Shouldn't Use Wildcards in Pathnames
258
1
15.07 Getting a List of Matching Files with grep -1
258
1
15.08 Getting a List of Non-Matching Files with grep -c
259
1
15.09 nom: List Files that Don't Match a Wildcard
260
1
15.10 Wildcards that Match Only Directories
261
2
Chapter 16: Where Did I Put That?
263
26
16.01 Everything but the find Command
263
1
16.02 Finding Oldest or Newest Files with Is -t and Is -u
263
2
16.03 Reordering Is Listings
265
2
16.04 List All Subdirectories with Is -R
267
1
16.05 The Three UNIX File Times
267
1
16.06 clf, cls: "Compressed" Is Listings
267
2
16.07 Is Shortcuts: ll, lf, lg, etc.
269
1
16.08 The Is -d Option
270
1
16.09 An Alias to List Recently Changed Files
271
1
16.10 findcmd: Find a Command in Your Search Path
271
1
16.11 Showing Hidden Files with Is -A and -a
272
1
16.12 Useful Is Aliases
273
1
16.13 Can't Access a File? Look for Spaces in the Name
274
1
16.14 Showing Non-Printable Characters in Filenames
275
1
16.15 Script with a:-) for UNIX Converts: dir
276
1
16.16 Picking a Unique Filename Automatically
276
1
16.17 Getting Directory Name from a File's Pathname
277
1
16.18 Listing Files You've Created/Edited Today
277
1
16.19 stree: Simple Directory Tree
278
1
16.20 The vtree Visual Directory Tree Programs
279
1
16.21 Finding All Directories with the Same Name
280
1
16.22 Comparing Two Directory Trees with dircmp
281
1
16.23 Comparing Filenames in Two Directory Trees
282
1
16.24 Counting Files by Types
282
1
16.25 Listing Files by Age and Size
283
1
16.26 Finding Text Files with findtext
284
2
16.27 newer: Print the Name of the Newest File
286
1
16.28 Oldlinks: Find Unconnected Symbolic Links
286
1
16.29 sls: Super Is with Format You Can Choose
287
2
Chapter 17: Finding Files with find
289
25
17.01 The find Command Is Great
289
2
17.02 Delving Through a Deep Directory Tree
291
1
17.03 Don't Forget -print
292
1
17.04 Looking for Files with Particular Names
293
1
17.05 Searching for Old Files
293
1
17.06 Be an Expert on find Search Operators
294
2
17.07 The Times that find Finds
296
1
17.08 Exact File Time Comparisons
296
1
17.09 Problems with -newer
297
1
17.10 Running Commands on What You Find
297
2
17.11 Using -exec to Create Custom Tests
299
1
17.12 Finding Many Things with One Command
300
1
17.13 Searching for Files by Type
301
1
17.14 Searching for Files by Size
302
1
17.15 Searching for Files by Permission
302
1
17.16 Searching by Owner and Group
303
1
17.17 Duplicating a Directory Tree
303
1
17.18 Using "Fast find"
304
2
17.19 Finding Files (Much) Faster with a find Database
306
2
17.20 grepping a Directory Tree (and a Gotcha)
308
1
17.21 lookfor: Which File Has that Word?
309
1
17.22 Finding the Links to a File
310
1
17.23 Finding Files with -prune
311
1
17.24 Skipping Some Parts of a Tree in find
312
1
17.25 Keeping find From Searching Networked Filesystems
313
1
Chapter 18: Linking, Renaming, and Copying Files
314
20
18.01 What's So Complicated About Copying Files?
314
1
18.02 What's Really in a Directory
315
1
18.03 Files with Two or More Names
316
2
18.04 More About Links
318
2
18.05 Creating and Removing Links
320
1
18.06 Stale Symbolic Links
321
2
18.07 Linking Directories
323
1
18.08 Showing the Actual Filenames for Symbolic Links
324
1
18.09 Renaming, Copying, or Comparing a Set of Files
325
1
18.10 There's More than One Way to Do It
325
1
18.11 Renaming Files with ren
326
2
18.12 Renaming a List of Files Interactively
328
1
18.13 One More Way to Do It
328
1
18.14 Relinking Multiple Symbolic Links
329
1
18.15 Copying Directory Trees with cp -r
329
2
18.16 Copying Directory Trees with (tar 1 tar)
331
3
Chapter 19: Creating and Reading Archives
334
9
19.01 Packing Up and Moving
334
1
19.02 Introduction to Shell Archives
335
1
19.03 unshar: Unarchive a Shell Archive
336
1
19.04 A Simple Version of unshar
337
1
19.05 Using tar to Create and Unpack Archives
337
2
19.06 GNU tar Sampler
339
1
19.07 Extracting Files from a Compressed Archive
340
1
19.08 Problems with Verbose tar
340
1
19.09 A System V Tape Archiver: cpio
341
2
Chapter 20: Backing Up Files
343
19
20.01 tar in a Nutshell
343
1
20.02 Make Your Own Backups
344
1
20.03 How to Make Backups with a Local Tape Drive
345
2
20.04 Restoring Files from Tape with tar
347
2
20.05 Using tar to a Remote Tape Drive
349
1
20.06 Writing a Tape Drive on a Remote Machine
349
2
20.07 Creating a Timestamp File for Selective Backups
351
1
20.08 Telling tar Which Files to Exclude or Include
352
3
20.09 When a Program Doesn't Understand Wildcards
355
1
20.10 Avoid Absolute Paths with tar
355
1
20.11 Getting tar's Arguments in the Right Order
356
1
20.12 Protecting Files with SCCS or RCS
357
1
20.13 SCCS Basics
357
2
20.14 RCS Basics
359
1
20.15 List RCS Revision Numbers with rcsrevs
360
2
Chapter 21: More About Managing Files
362
13
21.01 A Grab-Bag
362
1
21.02 A Better Place for Temporary Files: /tmp
362
1
21.03 Unique Names for Temporary Files
363
1
21.04 Why Both /tmp and /usr /tmp?
364
1
21.05 What Good Is a File's Last Access Time?
365
1
21.06 A File's Inode Change (not "Creation"!) Time
366
1
21.07 Setting File Modification Time with touch
366
1
21.08 The MAILCHECK and mail Variables Check More than Mail
367
3
21.09 Keep File Printouts Up-to-Date Automatically with make
370
1
21.10 Keep a Directory Listing at Top of the Screen: dirtop
370
1
21.11 Safer Removing, Moving, and Copying
371
1
21.12 Copying Files to a Directory
372
1
21.13 Read an Incode with stat
373
1
21.14 Automatically Appending the Date to a Filename
373
2
Chapter 22: File Security, Ownership, and Sharing
375
24
22.01 Introduction to File Ownership and Security
375
1
22.02 Tutorial on File and Directory Permissions
375
4
22.03 Who Will Own a New File?
379
1
22.04 Setting an Exact umask
380
1
22.05 Group Permissions in a Directory with the setgid Bit
380
1
22.06 Protecting Files with the Sticky Bit
381
1
22.07 Using chmod to Change File Permission
382
1
22.08 The Handy chmod = Operator
383
1
22.09 Protect Important Files: Make Them Unwritable
384
1
22.10 cx, cw, c-w: Quick File Permission Changes
385
1
22.11 A Loophole: Modifying Files Without Write Access
385
1
22.12 A Directory that People Can Access but Can't List
386
2
22.13 Groups and Group Ownership
388
1
22.14 Add Users to a Group to Deny Permission
389
1
22.15 Juggling Permissions
389
2
22.16 Copying Permissions with cpmod
391
1
22.17 Ways of Improving the Security of crypt
391
1
22.18 Clear Your Terminal for Security, to Stop Burn-in
392
1
22.19 Shell Scripts Must be Readable and (Usually) Executable
393
1
22.20 Why Can't You Change File Ownership Under BSD UNIX?
394
1
22.21 How to Change File Ownership Without chown
394
1
22.22 The su Command Isn't Just for the Superuser
395
4
Chapter 23: Removing Files
399
18
23.01 The Cycle of Creation and Destruction
399
1
23.02 rm and Its Dangers
399
2
23.03 Tricks for Making rm Safer
401
1
23.04 Answer "Yes" or "No" Forever with yes
401
1
23.05 Remove Some, Leave Some
402
1
23.06 A Faster Way to Remove Files Interactively
402
1
23.07 Safer File Deletion in Some Directories
403
1
23.08 Safe Delete: Pros and Cons
404
1
23.09 delete: Protecting Files from Accidental Deletion
404
3
23.10 Deletion with Prejudice: rm -f
407
1
23.11 Deleting Files with Odd Names
407
1
23.12 Using Wildcards to Delete Files with Strange Names
408
1
23.13 Deleting Files with the Null Name
409
1
23.14 Handling a Filename Starting with a Dash (-)
409
1
23.15 Using unlink to Remove a File with a Strange Name
410
1
23.16 Removing a Strange File by its I-number
411
1
23.17 Problems Deleting Directories
411
1
23.18 How Making and Deleting Directories Works
412
1
23.19 Deleting (BSD) Manual Pages that Aren't Read
413
1
23.20 Deleting Stale Files
413
2
23.21 Removing Every File but One
415
1
23.22 Using find to Clear Out Unneeded Files
415
2
Chapter 24: Other Ways to Get Disk Space
417
20
24.01 Instead of Removing a File, Empty It
417
1
24.02 Save Space with "Bit Bucket" Log Files and Mailboxes
418
1
24.03 Unlinking Open Files Isn't Good Idea
419
1
24.04 Save Space with a Link
420
1
24.05 Limiting File Sizes
420
1
24.06 Save Space with Tab Characters
421
1
24.07 Compressing Files to Save Space
421
2
24.08 Save Space: tar and compress a Directory Tree
423
1
24.09 How Much Disk Space?
424
2
24.10 zloop: Run a Command on Compressed Files
426
1
24.11 Edit Compressed Files with zvi, zex, and zed
427
1
24.12 Compressing a Directory Tree: Fine-Tuning
428
1
24.13 Save Space in Executable Files with strip
429
1
24.14 Don't Use Strip Carelessly
430
1
24.15 Trimming a Directory
430
1
24.16 Trimming a Huge Directory
431
1
24.17 Disk Quotas
432
1
24.18 Huge Files Might Not Take a Lot of Disk Space
433
4
Part Four: Looking Inside Files
437
88
Chapter 25: Showing What's in a File
437
17
25.01 Cracking the Nut
437
1
25.02 Four Ways to Skin a cat
437
2
25.03 Using more to Page Through Files
439
1
25.04 The "less" Pager: More than "more"
440
1
25.05 Page Through Compressed, RCS, Unprintable Files
440
1
25.06 What's in That White Space?
441
1
25.07 Show Non-Printing Characters with cat -v or od -c
442
2
25.08 Finding File Types
444
1
25.09 Adding and Deleting White Space
445
1
25.10 Squash Extra Blank Lines
446
1
25.11 crush: A cat that Skips all Blank Lines
446
1
25.12 Double Space, Triple Space
447
1
25.13 pushin: Squeeze Out Extra White Space
447
1
25.14 How to Look at the End of a File: tail
448
1
25.15 Finer Control on tail
449
1
25.16 How to Look at a File as It Grows
449
1
25.17 An Alias in Case You Don't Have tail
450
1
25.18 Watching Several Files Grow
450
1
25.19 Reverse Lines in Long Files with flip
451
1
25.20 Printing the Top of a File
452
1
25.21 Numbering Lines
452
2
Chapter 26: Regular Expressions (Pattern Matching)
454
21
26.01 That's an Expression
454
1
26.02 Don't Confuse Regular Expressions with Wildcards
455
1
26.03 Understanding Expressions
456
2
26.04 Using Metacharacters in Regular Expressions
458
7
26.05 Getting Regular Expressions Right
465
1
26.06 Just What Does a Regular Expression Match?
466
1
26.07 Limiting the Extent of a Match
467
1
26.08 I Never Meta Character I Didn't Like
468
1
26.09 Valid Metacharacters for Different UNIX Programs
469
1
26.10 Pattern Matching Quick Reference with Examples
470
5
Chapter 27: Searching Through Files
475
17
27.01 Different Versions of grep
475
1
27.02 Searching for Text with grep
476
1
27.03 Finding Text That Doesn't Match
477
1
27.04 Finding a Pattern Only When It's a Word
477
1
27.05 Extended Searching for Text with egrep
478
1
27.06 Fast grep Isn't
479
1
27.07 grepping for a List of Patterns
480
1
27.08 glimpse and agrep
480
2
27.09 New greps Are Much Faster
482
1
27.10 Search RCS Files with rcsgrep
483
1
27.11 A Multiline Context grep Using sed
484
1
27.12 Make Custom grep Commands (etc.) with perl
485
1
27.13 More grep-like Programs Written in Perl
486
1
27.14 Compound Searches
487
1
27.15 Narrowing a Search Quickly
488
1
27.16 Faking Case-Insensitive Searches
489
1
27.17 Finding a Character in a Column
489
1
27.18 Fast Searches and Spelling Checks with "look"
490
1
27.19 Finding Words Inside Binary Files
490
1
27.20 A Highlighting grep
491
1
Chapter 28: Comparing Files
492
18
28.01 Checking Differences with diff
492
2
28.02 Comparing Three Different Versions with diff3
494
1
28.03 Context diffs
495
2
28.04 Side-by-Side diffs: sdiff
497
1
28.05 Comparing Files Alongside One Another
497
1
28.06 Choosing Sides with sdiff
498
1
28.07 diff for Very Long Files: bdiff
498
1
28.08 More Friendly diff Output
499
1
28.09 ex Scripts Built by diff
500
2
28.10 Problems with diff and Tabstops
502
1
28.11 cmp and diff
503
1
28.12 Comparing Two Files with comm
503
2
28.13 make Isn't Just for Programmers!
505
2
28.14 Even More Uses for make
507
1
28.15 Show Changes in a troff File with diffmk
508
2
Chapter 29: Spell Checking, Word Counting, and Textual Analysis
510
15
29.01 The UNIX spell Command
510
1
29.02 Check Spelling Interactively with ispell
511
1
29.03 How Do I Spell That Word?
512
1
29.04 Inside spell
513
2
29.05 Adding Words to ispell's Dictionary
515
2
29.06 Counting Lines, Words, and Characters: wc
517
2
29.07 Count How Many Times Each Word Is Used
519
1
29.08 Find a a Doubled Word
520
1
29.09 Looking for Closure
520
2
29.10 Just the Words, Please
522
3
Part Five: Text Editing
525
168
Chapter 30: vi Tips and Tricks
525
34
30.01 The vi and ex Editors: Why So Much Material?
525
1
30.02 What We Cover
525
1
30.03 Mice vs. vi
526
2
30.04 Editing Multiple Files with vi
528
1
30.05 Edits Between Files
529
1
30.06 Local Settings for vi and ex
530
1
30.07 Using Buffers to Move or Copy Text
531
1
30.08 Get Back What You Deleted with Numbered Buffers
531
1
30.09 Using Search Patterns and Global Commands
532
1
30.10 Confirming Substitutions in ex and vi
533
1
30.11 Keep Your Original File, Write to a New File
534
1
30.12 Saving Part of a File
534
1
30.13 Appending to an Existing File
535
1
30.14 Moving Blocks of Text by Patterns
535
1
30.15 Useful Global Commands (with Pattern Matches)
536
1
30.16 Counting Occurrences; Stopping Search Wraps
537
1
30.17 Capitalizing Every Word on a Line
538
1
30.18 Setting vi Options Automatically for Individual Files
539
1
30.19 Modelines: Bug or Feature?
539
1
30.20 Multiple Editor Setup Files; Starting with a Search
540
1
30.21 Per File Setups in Separate Files
541
1
30.22 Filtering Text Through a UNIX Command
541
3
30.23 Safer vi Filter-Throughs
544
1
30.24 vi/ex File Recovery vs. Networked Filesystems
545
1
30.25 vi -r May not Write Recovered Buffer When You Exit
546
1
30.26 Shell Escapes
546
1
30.27 vi Compound Searches
547
1
30.28 Keep Track of Functions and Included Files
548
2
30.29 Setting Multiple tags Files
550
1
30.30 vi Outsmarts Dual-Function Function Keys
550
1
30.31 vi Word Abbreviation
550
1
30.32 Using vi Abbreviations as Commands
551
1
30.33 Fixing Typos with vi Abbreviations
552
1
30.34 vi Line Commands vs. Character Commands
553
1
30.35 Out of Temporary Space? Use Another Directory
554
1
30.36 The ex Open Mode Can Be Handy
555
2
30.37 Neatening Lines
557
1
30.38 Finding Your Place with Undo
557
2
Chapter 31: Creating Custom Commands in vi
559
20
31.01 Why Type More Than You Have To?
559
1
31.02 Save Time and Typing with the vi map Commands
560
2
31.03 What You Lose When You Use map!
562
1
31.04 vi @-Functions
563
2
31.05 Keymaps for Pasting into a Window Running vi
565
1
31.06 Protecting Keys from Interpretation by ex
566
1
31.07 Maps for Repeated Edits
567
1
31.08 More Examples of Mapping Keys in vi
568
2
31.09 Good Stuff for Your exrc File
570
3
31.10 Repeating a vi Keymap
573
1
31.11 Typing in Uppercase Without CAPS LOCK
574
1
31.12 Text-Input Mode Cursor Motion with No Arrow Keys
574
2
31.13 Making Cursor Keys Work in vi Text-input Mode
576
1
31.14 Don't Lose Important Functions with vi Maps: Use noremap
576
1
31.15 Fooling vi into Allowing Complex Macros
577
1
31.16 vi Macro for Splitting Long Lines
577
2
Chapter 32: GNU Emacs
579
12
32.01 Emacs: The Other Editor
579
1
32.02 Emacs Features: A Laundry List
580
1
32.03 Customizations and How to Avoid Them
581
1
32.04 Backup and Auto-Save Files
582
1
32.05 Putting Emacs in Overwrite Mode
583
1
32.06 Command Completion
583
1
32.07 Mike's Favorite Time Savers
584
1
32.08 Rational Searches
585
1
32.09 Unset PWD Before Using Emacs
586
1
32.10 Inserting Binary Characters into Files
586
1
32.11 Using Word Abbreviation Mode
587
1
32.12 Getting Around Emacs Flow Control Problems
588
1
32.13 An Absurd Amusement
589
2
Chapter 33: Batch Editing
591
22
33.01 Why Line Editors Aren't Dinosaurs
591
1
33.02 Writing Editing Scripts
592
1
33.03 Line Addressing
593
1
33.04 Useful ex Commands
594
2
33.05 Running Editing Scripts Within vi
596
1
33.06 Change Many Files by Editing Just One
597
1
33.07 ed/ex Batch Edits: Avoid Errors When No Match
598
1
33.08 Batch Editing Gotcha: Editors Bomb on Big Files
599
1
33.09 patch: Generalized Updating of Files that Differ
599
2
33.10 Quick Globals from the Command Line with qsubst
601
1
33.11 Quick Reference: awk
602
9
33.12 Versions of awk
611
2
Chapter 34: The Sed Stream Editor
613
34
34.01 Two Things You Must Know About sed
613
1
34.02 Invoking sed
614
1
34.03 Testing and Using a sed Script: checksed, runsed
614
2
34.04 sed Addressing Basics
616
2
34.05 Order of Commands in a Script
618
1
34.06 One Thing at a Time
619
1
34.07 Delimiting a Regular Expression
619
1
34.08 Newlines in a sed Replacement
620
1
34.09 Referencing the Search String in a Replacement
621
1
34.10 Referencing the Portions of a Search String
621
1
34.11 Search & Replacement: One Match Among Many
622
1
34.12 Transformations on Text
623
1
34.13 Hold Space: The Set-Aside Buffer
623
2
34.14 Transforming Part of a Line
625
2
34.15 Making Edits Across Line Boundaries
627
3
34.16 The Deliberate Scrivener
630
2
34.17 Searching for Patterns Split Across Lines
632
2
34.18 Multiline Delete
634
1
34.19 Making Edits Everywhere Except
635
1
34.20 The sed Test Command
636
1
34.21 Uses of the sed Quit Command
637
1
34.22 Dangers of the sed Quit Command
638
1
34.23 sed Newlines, Quoting, and Backslashes in a Shell Script
638
1
34.24 Quick Reference: sed
638
9
Chapter 35: You Can't Quite Call This Editing
647
25
35.01 And Why Not?
647
1
35.02 Neatening Text with fmt
648
1
35.03 Alternatives to fmt
649
1
35.04 recomment: Clean Up Program Comment Blocks
649
2
35.05 Remove Mail/News Headers with behead
651
1
35.06 Low-Level File Butchery with dd
652
1
35.07 Offset: Indent Text
652
1
35.08 Centering Lines in a File
653
1
35.09 Splitting Files at Fixed Points: split
654
2
35.10 Splitting Files by Context: csplit
656
3
35.11 Hacking on Characters with tr
659
1
35.12 Converting Between ASCII and EBCDIC
660
1
35.13 Other Conversions with dd
661
1
35.14 Cutting Columns or Fields with cut
662
1
35.15 Cutting Columns with colrm
662
1
35.16 Make Columns Automatically with cols
663
1
35.17 Making Text in Columns with pr
664
2
35.18 Pasting Things in Columns
666
1
35.19 Joining Lines with join
666
1
35.20 Quick Reference: uniq
667
1
35.21 Using IFS to Split Strings
668
1
35.22 Straightening Jagged Columns
669
1
35.23 Rotating Text
670
2
Chapter 36: Sorting
672
11
36.01 Putting Things in Order
672
1
36.02 Sort Fields: How sort Sorts
673
2
36.03 Changing the Field Delimiter
675
1
36.04 Confusion with White Space Field Delimiters
675
2
36.05 Alphabetic and Numeric Sorting
677
1
36.06 Miscellaneous sort Hints
678
2
36.07 Sorting Multiline Entries
680
1
36.08 lensort: Sort Lines by Length
681
1
36.09 Sorting a List of People by Last Name
681
2
Chapter 37: Perl, a Pathologically Eclectic Rubbish Lister
683
10
37.01 What We Do and Don't Tell You About Perl
683
1
37.02 Why Learn Perl? # 1
683
3
37.03 Three Great Virtues of a Programmer
686
1
37.04 Why Learn Perl? #2
686
3
37.05 And Now, Perl 5
689
4
Part Six: Managing Processes
693
54
Chapter 38: Starting, Stopping, and Killing Processes
693
19
38.01 What's in This Chapter
693
1
38.02 fork and exec
694
1
38.03 Managing Processes: Overall Concepts
695
2
38.04 Subshells
697
1
38.05 The ps Command
698
2
38.06 The Controlling Terminal
700
1
38.07 Why ps Prints Some Commands in Parentheses
701
1
38.08 What Are Signals?
701
2
38.09 Killing Foreground Jobs
703
1
38.10 Destroying Processes with kill
703
2
38.11 Printer Queue Watcher: A Restartable Daemon Shell Script
705
1
38.12 Killing All Your Processes
706
1
38.13 Interactively Kill Processes Matching a Pattern
707
1
38.14 Processes Out of Control? Just STOP Them
708
1
38.15 Cleaning Up an Unkillable Process
709
1
38.16 Why You Can't Kill a Zombie
709
1
38.17 Automatically Kill Background Processes on Logout in csh
710
1
38.18 nohup
711
1
Chapter 39: Time and Performance
712
18
39.01 Which Time Is It?
712
1
39.02 Timing Programs
712
1
39.03 The csh time variable
713
3
39.04 Average Command Runtimes with runtime
716
1
39.05 Why Is the System So Slow?
717
2
39.06 lastcomm: What Commands Are Running
719
1
39.07 Checking System Load: Uptime
720
1
39.08 A Big Environment Can Slow You Down
721
1
39.09 Know When to Be "nice" to Other Users and When Not to
722
3
39.10 A nice Gotcha
725
1
39.11 Changing a Job's Priority Under BSD UNIX
725
1
39.12 What Makes Your Computer Slow? How Do You Fix It?
726
4
Chapter 40: Delayed Execution
730
17
40.01 Off-Peak Job Submission
730
1
40.02 Waiting a Little While: sleep
731
1
40.03 The at Command
732
1
40.04 Choosing the Shell Run (We Hope) by at
732
1
40.05 Avoiding Other at and cron Jobs
733
1
40.06 System V.4 Batch Queues
734
1
40.07 Making Your at Jobs Quiet
735
1
40.08 Automatically Restarting at Jobs
735
1
40.09 Checking and Removing Jobs
736
1
40.10 nextday, nextweekday: Tomorrow or Next Weekday
737
1
40.11 Send Yourself Reminder Mail
738
1
40.12 Periodic Program Execution: The cron Facility
739
3
40.13 Adding crontab Entries
742
1
40.14 Including Standard Input Within a cron Entry
742
1
40.15 crontab Script Makes crontab Editing Easier/Safer
743
4
Part Seven: Terminals and Printers
747
74
Chapter 41: Terminal and Serial Line Settings
747
22
41.01 Delving a Little Deeper
747
1
41.02 stty and All That Stuff
748
6
41.03 Find Out Terminal Settings with stty
754
1
41.04 How UNIX Handles TAB Characters
754
3
41.05 Why Some Systems Backspace over Prompts
757
1
41.06 Using sleep to Keep Port Settings
758
1
41.07 Reading Verrry Long Lines from Terminal
758
1
41.08 ptys and Window Systems
759
1
41.09 Commands to Adjust Your Terminal
759
2
41.10 Using terminfo Capabilities in Shell Programs
761
1
41.11 How termcap and terminfo Describe Terminals
762
5
41.12 Your Terminal's Special Keys
767
2
Chapter 42: Problems with Terminals
769
16
42.01 Making Sense Out of the Terminal Mess
769
2
42.02 Fixing a Hung Terminal or Job
771
3
42.03 Why Changing TERM Sometimes Doesn't Work
774
1
42.04 Checklist for Resetting a Messed Up Terminal
774
3
42.05 Checklist: Screen Size Messed Up?
777
3
42.06 Screen Size Testing Files
780
2
42.07 termtest: Send Repeated Characters to Terminal
782
1
42.08 Errors Erased Too Soon? Try These Workarounds
783
2
Chapter 43: Printing
785
36
43.01 Introduction to Printing
785
2
43.02 Introduction to Printing on UNIX
787
2
43.03 Printer Control with lpc
789
1
43.04 Using Different Printers
790
1
43.05 Using Symbolic Links for Spooling
791
1
43.06 Printing to a Terminal Printer
792
1
43.07 Quick-and-Dirty Formatting Before Printing
792
2
43.08 Fixing Margins with pr and fold
794
1
43.09 Indenting Text for Printing
794
1
43.10 Filename Headers Above Files Without pr
795
1
43.11 Big Letters: banner
796
1
43.12 Typesetting Overview
797
3
43.13 The Text Formatters nroff, troff, ditroff
800
1
43.14 nroff/troff and Macro Packages
801
1
43.15 From a Source File to the Printer
801
2
43.16 groff
803
1
43.17 Don't Have nroff? Try gnroff or awf
804
1
43.18 How nroff Makes Bold and Underline; How to Remove It
804
2
43.19 Removing Leading Tabs and Other Trivia
806
1
43.20 Displaying a troff Macro Definition
807
1
43.21 Preprocessing troff Input with sed
808
2
43.22 Converting Text Files to PostScript
810
1
43.23 psselect: Print Some Pages from a PostScript file
811
1
43.24 Other PostScript Utilities
812
1
43.25 The Portable Bitmap Package
813
8
Part Eight: Shell Programming
821
98
Chapter 44: Shell Programming for the Uninitiated
821
28
44.01 Everyone Should Learn Some Shell Programming
821
2
44.02 Writing a Simple Shell Program
823
2
44.03 What's a Shell, Anyway?
825
1
44.04 Testing How Your System Executes Files
826
2
44.05 Test String Values with Bourne Shell case
828
1
44.06 Pattern Matching in case Statements
828
1
44.07 Exit Status of UNIX Processes
829
1
44.08 Test Exit Status with the if Statement
830
1
44.09 Testing Your Success
831
1
44.10 Loops That Test Exit Status
832
1
44.11 Set Exit Status of a Shell (Script)
833
1
44.12 Trapping Exits Caused by Interrupts
834
2
44.13 read: Reading from the Keyboard
836
1
44.14 Putting awk, sed, etc,. Inside Shell Scripts
836
2
44.15 Handling Command-Line Arguments in Shell Scripts
838
1
44.16 Handling Command-Line Arguments with a for Loop
839
1
44.17 Handling Arguments with while and shift
840
2
44.18 Standard Command-Line Parsing
842
2
44.19 The Bourne Shell set Command
844
1
44.20 test: Testing Files and Strings
845
1
44.21 Picking a Name for a New Command
846
1
44.22 Finding a Program Name; Multiple Program Names
846
1
44.23 Reading Files with the and source Commands
847
2
Chapter 45: Shell Programming for the Initiated
849
45
45.01 Beyond the Basics
849
2
45.02 The Story of : # #!
851
1
45.03 Don't Need a Shell for Your Script? Don't Use One
851
1
45.04 Fun with #!
852
1
45.05 A File That Shows Itself and What # ! Does
853
2
45.06 Making Sure Your Script Runs with Bourne Shell, Without #!
855
1
45.07 The exec Command
855
1
45.08 Handling Signals to Child Processes
856
1
45.09 The Unappreciated Bourne Shell":" Operator
857
1
45.10 Removing a File Once It's Opened--for Security
858
1
45.11 The Multipurpose jot Command
859
4
45.12 Parameter Substitution
863
1
45.13 Save Disk Space and Programming
864
1
45.14 Finding the Last Command-Line Argument
865
1
45.15 How to Unset all Command-Line Parameters
865
1
45.16 Standard Input to a for Loop
866
1
45.17 Making a for Loop with Multiple Variables
866
1
45.18 Using basename and dirname
867
1
45.19 A While Loop with Several Loop Control Commands
868
1
45.20 Overview: Open Files and File Descriptors
869
2
45.21 n greater than &m: Standard Output and Standard Error
871
4
45.22 Handling Files Line-by-Line
875
3
45.23 The Ins and Outs of Redirected I/O Loops
878
1
45.24 A Shell Can Read a Script from its Standard Input, But
879
1
45.25 Shell Scripts On-the-Fly from Standard Input
880
1
45.26 Quoted hereis Document Terminators: sh vs. csh
881
1
45.27 Turn Off echo for "Secret" Answers
881
1
45.28 Quick Reference: expr
882
2
45.29 Testing Characters in a String with expr
884
1
45.30 Grabbing Parts of a String
884
2
45.31 Nested Command Substitution
886
2
45.32 A Better read Command: grabchars
888
1
45.33 Testing Two Strings With One case Statement
889
1
45.34 Arrays in the Bourne Shell
890
1
45.35 Using a Control Character in a Script
890
1
45.36 Shell Lockfile
891
3
Chapter 46: Shell Script Debugging and Gotchas
894
10
46.01 Tips for Debugging Shell Scripts
894
2
46.02 Quoting Trouble? Think, Then Use echo
896
1
46.03 Bourne Shell Debugger Shows a Shell Variable
896
1
46.04 Stop Syntax Errors in Numeric Tests
897
1
46.05 Stop Syntax Errors in String Tests
897
1
46.06 Watch Out for Bourne Shell -e Bug
898
1
46.07 Quoting and Command-Line Parameters
898
2
46.08 Test Built-In Commands for Failure
900
1
46.09 If Command Doesn't Return a Status, Test the Error Messages
901
1
46.10 A Portable echo Command
902
2
Chapter 47: C Shell Programming NOT
904
15
47.01 Why Not?
904
1
47.02 C Shell Programming Considered Harmful
904
7
47.03 Conditional Statements with if
911
1
47.04 C Shell Variable Operators and Expressions
911
3
47.05 Using C Shell Arrays
914
1
47.06 Quick Reference: C Shell switch Statement
915
4
Part Nine: Miscellaneous
919
114
Chapter 48: Office Automation
919
20
48.01 Well, What Else Could We Call It?
919
1
48.02 Online Phone and Address Lists
920
1
48.03 A Scretchpad on Your Screen
921
1
48.04 Automatics Reminder and More: calender
922
2
48.05 leave: A Maddening Aid to Quitting on Time
924
1
48.06 Get Calendar for Any Month or Year: cal
925
1
48.07 cal That Marks Today's Date
926
1
48.08 Calendar for 132-Column Terminals or Printers
927
1
48.09 PostScript Calendars with pcal
927
3
48.10 Working with Names and Addresses
930
5
48.11 The index Database Program
935
3
48.12 Using index with a Filter
938
1
Chapter 49: Working with Numbers
939
6
49.01 bc: Simple Match at the Shell Prompt
939
1
49.02 bc: Hexadecimal or Binnary Conversion
940
1
49.03 Gotchas in Base Conversion
941
1
49.04 bc's Sine and Cosine Are in Radians
941
1
49.05 Base Conversion Using cvtbase
942
1
49.06 Quick Arithmetic with expr
942
1
49.07 Total a Column with addup
943
1
49.08 It's Great to Have a Spreadsheet
943
1
49.09 Business Graphics with ipl
944
1
Chapter 50: Help--Online Documentation, etc.
945
17
50.01 UNIX Online Documentation
945
2
50.02 The apropos Command
947
1
50.03 apropos on Systems Without apropos
947
2
50.04 whatis: One-Line Command Summaries
949
1
50.05 whereis: Finding Where a Command Is Located
949
1
50.06 Searching Online Manual Pages
950
1
50.07 How UNIX Systems Remember Their Name
951
1
50.08 Which Version Am I Using?
951
2
50.09 Reading a Permuted Index
953
1
50.10 Make Your Own Man Pages Without Learning troff
954
2
50.11 Writing a Simple Man Page With the-man Macros
956
2
50.12 Common UNIX Error Messages
958
4
Chapter 51: Miscellaneous Useful Programs and Curiosities
962
9
51.01 We Are Finally Getting to the Bottom of the Bucket
962
1
51.02 How UNIX Keeps Time
962
1
51.03 ASCII Characters: Listing and Getting Values
963
1
51.04 Who's On?
964
1
51.05 Copy What You Do With script
965
1
51.06 Cleaning script Files
966
1
51.07 When You Get Impatient
966
1
51.08 Type Bang Splat. Don't Forget the Rabbit Ears
967
1
51.09 Making a "Login" Shell
968
1
51.10 The date Command
969
1
51.11 Making an Arbitary-Size File for Testing
969
1
51.12 You Don't Have Enough Smileys?
970
1
Chapter 52: What's on the Disc
971
51
52.01 Introduction
971
1
52.02 Where Does Free Software End and UNIX Begin?
972
1
52.03 Shrink-Wrapped Software for UNIX
973
1
52.04 Quick Descriptions of What's on the Disc
974
18
52.05 Using the Power Tools of CD-ROM
992
12
52.06 Don't Have a CD-ROM Drive?
1004
1
52.07 Other Ways to Get the Software
1005
2
52.08 Building Programs from Source Code
1007
13
52.09 Software Support from RTR
1020
2
Chapter 53: Glossary
1022
11
Index
1033