AWK: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: Table of Contents * Why learn AWK? * Basic Structure * Executing an AWK script * Which shell to use with AWK? * Dynamic Variables * The Essenti...)
 
(awk)
Zeile 1: Zeile 1:
Table of Contents
This awk program deletes C-style comments (‘/* ... */’) [http://www.gnu.org/manual/gawk/html_node/Plain-Getline.html#Plain-Getline Link]<br>
 
negativ from above (print everythings between aAa and bBb)
 
<source lang="awk">#!/usr/bin/awk -f
    {
          if ((t = index($0, "Thread-11")) != 0) {
                print $0
              # value of `tmp' will be "" if t is 1
              tmp = substr($0, 1, t - 1)
              u = index(substr($0, t + 2), "*/")
              offset = t + 2
              while (u == 0) {
                    if (getline <= 0) {
                        m = "unexpected EOF or error"
                        m = (m ": " ERRNO)
                        print m > "/dev/stderr"
                        exit
                    }
                print $0
                    u = index($0, "(GUI.java:821)")
                    offset = 0
              }
              # substr expression will be "" if */
              # occurred at end of line
              #$0 = tmp substr($0, offset + u + 2)
          }
          #print $0
    }</source>
 
<br>
 
= Weitere Links<br>  =
 
[http://www-e.uni-magdeburg.de/urzs/awk/ awk - Eine Einführung]<br>
 
<br>
 
http://www.grymoire.com/Unix/Awk.html<br>
 
Table of Contents  


     * Why learn AWK?
     * Why learn AWK?
Zeile 71: Zeile 111:
     * AWK, NAWK, GAWK, or PERL  
     * AWK, NAWK, GAWK, or PERL  


<br>


http://www.grymoire.com/Unix/Awk.html
[[Category:Linux]]
 
[[Kategorie:Linux]]

Version vom 26. August 2009, 20:44 Uhr

This awk program deletes C-style comments (‘/* ... */’) Link

negativ from above (print everythings between aAa and bBb)

#!/usr/bin/awk -f
     {
          if ((t = index($0, "Thread-11")) != 0) {
                print $0
               # value of `tmp' will be "" if t is 1
               tmp = substr($0, 1, t - 1)
               u = index(substr($0, t + 2), "*/")
               offset = t + 2
               while (u == 0) {
                    if (getline <= 0) {
                         m = "unexpected EOF or error"
                         m = (m ": " ERRNO)
                         print m > "/dev/stderr"
                         exit
                    }
                print $0
                    u = index($0, "(GUI.java:821)")
                    offset = 0
               }
               # substr expression will be "" if */
               # occurred at end of line
               #$0 = tmp substr($0, offset + u + 2)
          }
          #print $0
     }


Weitere Links

awk - Eine Einführung


http://www.grymoire.com/Unix/Awk.html

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 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