Muutke küpsiste eelistusi

Effective AWK Programming, 4e [Pehme köide]

  • Formaat: Paperback / softback, 560 pages, kõrgus x laius x paksus: 233x177x30 mm, kaal: 968 g
  • Ilmumisaeg: 14-Apr-2015
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1491904615
  • ISBN-13: 9781491904619
Teised raamatud teemal:
  • Pehme köide
  • Hind: 43,68 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Tavahind: 51,39 €
  • Säästad 15%
  • Raamatu kohalejõudmiseks kirjastusest kulub orienteeruvalt 2-4 nädalat
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Tellimisaeg 2-4 nädalat
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 560 pages, kõrgus x laius x paksus: 233x177x30 mm, kaal: 968 g
  • Ilmumisaeg: 14-Apr-2015
  • Kirjastus: O'Reilly Media
  • ISBN-10: 1491904615
  • ISBN-13: 9781491904619
Teised raamatud teemal:
When processing text files, the awk language is ideal for handling data extraction, reporting, and data-reformatting jobs. This practical guide serves as both a reference and tutorial for POSIX-standard awk and for the GNU implementation, called gawk. This book is useful for novices and awk experts alike. In this thoroughly revised edition, author and gawk lead developer Arnold Robbins describes the awk language and gawk program in detail, shows you how to use awk and gawk for problem solving, and then dives into specific features of gawk. System administrators, programmers, webmasters, and other power users will find everything they need to know about awk and gawk. You will learn how to: Format text and use regular expressions in awk and gawk Process data using awk's operators and built-in functions Manage data relationships using associative arrays Define your own functions "Think in awk" with two full chapters of sample functions and programs Take advantage of gawk's many advanced features Debug awk programs with the gawk built-in debugger Extend gawk by writing new functions in C or C++ This book is published under the terms of the GNU Free Documentation License. You have the freedom to copy and modify this GNU manual. Royalties from the sales of this book go to the Free Software Foundation and to the author.
Foreword to the Third Edition xv
Foreword to the Fourth Edition xvii
Preface xix
Part I. The awk Language
1 Getting Started with awk
3(18)
How to Run awk Programs
3(8)
One-Shot Throwaway awk Programs
4(1)
Running awk Without Input Files
4(1)
Running Long Programs
5(1)
Executable awk Programs
6(1)
Comments in awk Programs
7(1)
Shell Quoting Issues
8(3)
Datafiles for the Examples
11(1)
Some Simple Examples
12(2)
An Example with Two Rules
14(1)
A More Complex Example
15(1)
awk Statements Versus Lines
16(2)
Other Features of awk
18(1)
When to Use awk
18(1)
Summary
19(2)
2 Running awk and gawk
21(18)
Invoking awk
21(1)
Command-Line Options
22(7)
Other Command-Line Arguments
29(1)
Naming Standard Input
30(1)
The Environment Variables gawk Uses
30(4)
The AWKPATH Environment Variable
31(1)
The AWKLIBPATH Environment Variable
32(1)
Other Environment Variables
32(2)
gawk's Exit Status
34(1)
Including Other Files into Your Program
35(1)
Loading Dynamic Extensions into Your Program
36(1)
Obsolete Options and/or Features
37(1)
Undocumented Options and Features
37(1)
Summary
37(2)
3 Regular Expressions
39(16)
How to Use Regular Expressions
39(1)
Escape Sequences
40(3)
Regular Expression Operators
43(3)
Using Bracket Expressions
46(2)
How Much Text Matches?
48(1)
Using Dynamic Regexps
49(1)
gawk-Specific Regexp Operators
50(2)
Case Sensitivity in Matching
52(2)
Summary
54(1)
4 Reading Input Files
55(34)
How Input Is Split into Records
55(5)
Record Splitting with Standard awk
55(3)
Record Splitting with gawk
58(2)
Examining Fields
60(1)
Nonconstant Field Numbers
61(1)
Changing the Contents of a Field
62(3)
Specifying How Fields Are Separated
65(6)
Whitespace Normally Separates Fields
66(1)
Using Regular Expressions to Separate Fields
66(1)
Making Each Character a Separate Field
67(1)
Setting FS from the Command Line
68(1)
Making the Full Line Be a Single Field
69(1)
Field-Splitting Summary
70(1)
Reading Fixed-Width Data
71(2)
Defining Fields by Content
73(2)
Multiple-Line Records
75(2)
Explicit Input with getline
77(8)
Using getline with No Arguments
78(1)
Using getline into a Variable
79(1)
Using getline from a File
80(1)
Using getline into a Variable from a File
80(1)
Using getline from a Pipe
81(1)
Using getline into a Variable from a Pipe
82(1)
Using getline from a Coprocess
83(1)
Using getline into a Variable from a Coprocess
83(1)
Points to Remember About getline
83(2)
Summary of getline Variants
85(1)
Reading Input with a Timeout
85(2)
Directories on the Command Line
87(1)
Summary
87(2)
5 Printing Output
89(22)
The print Statement
89(1)
print Statement Examples
90(1)
Output Separators
91(1)
Controlling Numeric Output with print
92(1)
Using printf Statements for Fancier Printing
93(7)
Introduction to the printf Statement
93(1)
Format-Control Letters
94(2)
Modifiers for printf Formats
96(3)
Examples Using printf
99(1)
Redirecting Output of print and printf
100(3)
Special Files for Standard Preopened Data Streams
103(1)
Special Filenames in gawk
104(1)
Accessing Other Open Files with gawk
104(1)
Special Files for Network Communications
104(1)
Special Filename Caveats
105(1)
Closing Input and Output Redirections
105(3)
Summary
108(3)
6 Expressions
111(30)
Constants, Variables, and Conversions
111(8)
Constant Expressions
111(3)
Using Regular Expression Constants
114(1)
Variables
115(2)
Conversion of Strings and Numbers
117(2)
Operators: Doing Something with Values
119(8)
Arithmetic Operators
119(2)
String Concatenation
121(1)
Assignment Expressions
122(3)
Increment and Decrement Operators
125(2)
Truth Values and Conditions
127(7)
True and False in awk
127(1)
Variable Typing and Comparison Expressions
128(4)
Boolean Expressions
132(2)
Conditional Expressions
134(1)
Function Calls
134(2)
Operator Precedence (How Operators Nest)
136(2)
Where You Are Makes a Difference
138(1)
Summary
139(2)
7 Patterns, Actions, and Variables
141(32)
Pattern Elements
141(7)
Regular Expressions as Patterns
142(1)
Expressions as Patterns
142(1)
Specifying Record Ranges with Patterns
143(2)
The BEGIN and END Special Patterns
145(2)
The BEGINFILE and ENDFILE Special Patterns
147(1)
The Empty Pattern
148(1)
Using Shell Variables in Programs
148(1)
Actions
149(1)
Control Statements in Actions
150(10)
The if-else Statement
150(1)
The while Statement
151(1)
The do-while Statement
151(1)
The for Statement
152(2)
The switch Statement
154(1)
The break Statement
155(1)
The continue Statement
156(1)
The next Statement
157(1)
The nextfile Statement
158(1)
The exit Statement
159(1)
Predefined Variables
160(12)
Built-in Variables That Control awk
160(3)
Built-in Variables That Convey Information
163(7)
Using ARGC and ARGV
170(2)
Summary
172(1)
8 Arrays in awk
173(18)
The Basics of Arrays
173(9)
Introduction to Arrays
173(2)
Referring to an Array Element
175(1)
Assigning Array Elements
176(1)
Basic Array Example
177(1)
Scanning All Elements of an Array
178(1)
Using Predefined Array Scanning Orders with gawk
179(3)
Using Numbers to Subscript Arrays
182(1)
Using Uninitialized Variables as Subscripts
183(1)
The delete Statement
184(1)
Multidimensional Arrays
185(2)
Scanning Multidimensional Arrays
187(1)
Arrays of Arrays
187(3)
Summary
190(1)
9 Functions
191(50)
Built-in Functions
191(29)
Calling Built-in Functions
191(1)
Numeric Functions
192(2)
String-Manipulation Functions
194(14)
Input/Output Functions
208(3)
Time Functions
211(6)
Bit-Manipulation Functions
217(2)
Getting Type Information
219(1)
String-Translation Functions
220(1)
User-Defined Functions
220(11)
Function Definition Syntax
221(2)
Function Definition Examples
223(1)
Calling User-Defined Functions
224(5)
The return Statement
229(1)
Functions and Their Effects on Variable Typing
230(1)
Indirect Function Calls
231(5)
Summary
236(5)
Part II. Problem Solving with awk
10 A Library of awk Functions
241(36)
Naming Library Function Global Variables
242(1)
General Programming
243(11)
Converting Strings to Numbers
244(1)
Assertions
245(2)
Rounding Numbers
247(1)
The Cliff Random Number Generator
247(1)
Translating Between Characters and Numbers
248(2)
Merging an Array into a String
250(1)
Managing the Time of Day
250(2)
Reading a Whole File at Once
252(1)
Quoting Strings to Pass to the Shell
253(1)
Datafile Management
254(5)
Noting Datafile Boundaries
254(2)
Rereading the Current File
256(1)
Checking for Readable Datafiles
257(1)
Checking for Zero-Length Files
257(1)
Treating Assignments as Filenames
258(1)
Processing Command-Line Options
259(5)
Reading the User Database
264(5)
Reading the Group Database
269(4)
Traversing Arrays of Arrays
273(2)
Summary
275(2)
11 Practical awk Programs
277(50)
Running the Example Programs
277(1)
Reinventing Wheels for Fun and Profit
278(21)
Cutting Out Fields and Columns
278(5)
Searching for Regular Expressions in Files
283(4)
Printing Out User Information
287(2)
Splitting a Large File into Pieces
289(1)
Duplicating Output into Multiple Files
290(2)
Printing Nonduplicated Lines of Text
292(4)
Counting Things
296(3)
A Grab Bag of awk Programs
299(24)
Finding Duplicated Words in a Document
299(1)
An Alarm Clock Program
300(2)
Transliterating Characters
302(2)
Printing Mailing Labels
304(2)
Generating Word-Usage Counts
306(2)
Removing Duplicates from Unsorted Text
308(1)
Extracting Programs from Texinfo Source Files
309(3)
A Simple Stream Editor
312(2)
An Easy Way to Use Library Functions
314(7)
Finding Anagrams from a Dictionary
321(2)
And Now for Something Completely Different
323(1)
Summary
323(4)
Part III. Moving Beyond Standard awk with gawk
12 Advanced Features of gawk
327(18)
Allowing Nondecimal Input Data
327(1)
Controlling Array Traversal and Array Sorting
328(6)
Controlling Array Traversal
328(5)
Sorting Array Values and Indices with gawk
333(1)
Two-Way Communications with Another Process
334(3)
Using gawk for Network Programming
337(1)
Profiling Your awk Programs
338(4)
Summary
342(3)
13 Internationalization with gawk
345(12)
Internationalization and Localization
345(1)
GNU gettext
346(2)
Internationalizing awk Programs
348(2)
Translating awk Programs
350(3)
Extracting Marked Strings
350(1)
Rearranging printf Arguments
351(1)
awk Portability Issues
352(1)
A Simple Internationalization Example
353(2)
gawk Can Speak Your Language
355(1)
Summary
355(2)
14 Debugging awk Programs
357(20)
Introduction to the gawk Debugger
357(2)
Debugging in General
357(1)
Debugging Concepts
358(1)
awk Debugging
359(1)
Sample gawk Debugging Session
359(4)
How to Start the Debugger
359(1)
Finding the Bug
360(3)
Main Debugger Commands
363(11)
Control of Breakpoints
364(1)
Control of Execution
365(2)
Viewing and Changing Data
367(2)
Working with the Stack
369(1)
Obtaining Information About the Program and the Debugger State
369(3)
Miscellaneous Commands
372(2)
Readline Support
374(1)
Limitations
374(1)
Summary
375(2)
15 Arithmetic and Arbitrary-Precision Arithmetic with gawk
377(16)
A General Description of Computer Arithmetic
377(2)
Other Stuff to Know
379(2)
Arbitrary-Precision Arithmetic Features in gawk
381(1)
Floating-Point Arithmetic: Caveat Emptor!
382(6)
Floating-Point Arithmetic Is Not Exact
382(2)
Getting the Accuracy You Need
384(1)
Try a Few Extra Bits of Precision and Rounding
385(1)
Setting the Precision
385(2)
Setting the Rounding Mode
387(1)
Arbitrary-Precision Integer Arithmetic with gawk
388(1)
Standards Versus Existing Practice
389(2)
Summary
391(2)
16 Writing Extensions for gawk
393(64)
Introduction
393(1)
Extension Licensing
394(1)
How It Works at a High Level
394(2)
API Description
396(35)
Introduction
397(2)
General-Purpose Data Types
399(3)
Memory Allocation Functions and Convenience Macros
402(1)
Constructor Functions
403(1)
Registration Functions
404(9)
Printing Messages
413(1)
Updating ERRNO
413(1)
Requesting Values
413(1)
Accessing and Updating Parameters
414(1)
Symbol Table Access
414(5)
Array Manipulation
419(9)
API Variables
428(1)
Boilerplate Code
429(2)
How gawk Finds Extensions
431(1)
Example: Some File Functions
431(11)
Using chdir() and stat()
431(3)
C Code for chdir() and stat()
434(6)
Integrating the Extensions
440(2)
The Sample Extensions in the gawk Distribution
442(10)
File-Related Functions
442(3)
Interface to fnmatch()
445(1)
Interface to fork(), wait(), and waitpid()
446(1)
Enabling In-Place File Editing
447(1)
Character and Numeric values: ord() and chr()
448(1)
Reading Directories
448(1)
Reversing Output
449(1)
Two-Way I/O Example
449(1)
Dumping and Restoring an Array
450(1)
Reading an Entire File
450(1)
Extension Time Functions
451(1)
API Tests
452(1)
The gawkextlib Project
452(1)
Summary
453
Part IV. Appendices
A The Evolution of the awk Language
457(12)
B Installing gawk
469(22)
C GNU General Public License
491(14)
Index 505
Arnold Robbins is a professional programmer and technical author who has worked with Unix systems since 1980 and has been using AWK since 1987. As a member of the POSIX 1003.2 balloting group, he helped shape the POSIX standard for AWK. Arnold is currently the maintainer of gawk and its documentation. He is coauthor of the sixth edition of O'Reilly's Learning the vi Editor.