Awk - 教程

Thu Nov 22 18:38:28 EST 2012

Part of the Unix tutorials And then there's My blog

Table of Contents

  • Why learn AWK?
  • Basic Structure
  • Executing an AWK script
  • Which shell to use with AWK?
  • Dynamic Variables
  • The Essential Syntax of AWK
  • Arithmetic Expressions
  • Unary arithmetic operators
  • The Autoincrement and Autodecrement Operators
  • Assignment Operators
  • Conditional expressions
  • Regular Expressions
  • And/Or/Not
  • Commands
  • AWK Built-in Variables
  • FS - The Input Field Separator Variable
  • OFS - The Output Field Separator Variable
  • NF - The Number of Fields Variable
  • NR - The Number of Records Variable
  • RS - The Record Separator Variable
  • ORS - The Output Record Separator Variable
  • FILENAME - The Current Filename Variable
  • Associative Arrays
  • Multi-dimensional Arrays
  • Example of using AWK's Associative Arrays
  • Output of the script
  • Picture Perfect PRINTF Output
  • PRINTF - formatting output
  • Escape Sequences
  • Format Specifiers
  • Width - specifying minimum field size
  • Left Justification
  • The Field Precision Value
  • Explicit File output
  • AWK Numerical Functions
  • Trigonometric Functions
  • Exponents, logs and square roots
  • Truncating Integers
  • "Random Numbers
  • The Lotto script
  • String Functions
  • The Length function
  • The Index Function
  • The Substr function
  • GAWK's Tolower and Toupper function
  • The Split function
  • NAWK's string functions
  • The Match function
  • The System function
  • The Getline function
  • The systime function
  • The Strftime function
  • User Defined Functions
  • AWK patterns
  • Formatting AWK programs
  • Environment Variables
  • ARGC - Number or arguments (NAWK/GAWK)
  • ARGV - Array of arguments (NAWK/GAWK)
  • ARGIND - Argument Index (GAWK only)
  • FNR (NAWK/GAWK)
  • OFMT (NAWK/GAWK)
  • RSTART, RLENGTH and match (NAWK/GAWK)
  • SUBSEP - Multi-dimensional array separator (NAWK/GAWK)
  • ENVIRON - environment variables (GAWK only)
  • IGNORECASE (GAWK only)
  • CONVFMT - conversion format (GAWK only)
  • ERRNO - system errors (GAWK only)
  • FIELDWIDTHS - fixed width fields (GAWK only)
  • AWK, NAWK, GAWK, or PERL

Copyright 1994,1995 Bruce Barnett and General Electric Company

Copyright 2001,2004,2013 Bruce Barnett

All rights reserved

You are allowed to print copies of this tutorial for your personaluse, and link to this page, but you are not allowed to make electroniccopies, or redistribute this tutorial in any form without permission.

Original version written in 1994 and published in the Sun Observer
Last Update: Wed Feb 6 07:02:35 EST 2013

Awk is an extremely versatile programming language for working onfiles. We'll teach you just enough to understand the examples in thispage, plus a smidgen.

The examples given below have the extensions of the executing script as part of the filename. Once you download it, and make it executable, you can rename it anything you want.  

你可能感兴趣的:(linux,shell,awk)