Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RE: AWK

wtnabe
February 15, 2014

RE: AWK

Introduction of Regular Expression and AWK on my own

wtnabe

February 15, 2014
Tweet

More Decks by wtnabe

Other Decks in Programming

Transcript

  1. Rough Classification POSIX ( Basic / Extended ) PCRE (Perl

    Compatible Regular Expression) PHP, Apache, GNU Grep, ... GNU ( Basic / Extended ) and more
  2. Basic Syntax Literal Character Meta Character / Escape Sequence Character

    List / Character Class Grouping and Back reference
  3. Elementary Operators ^ $ ( \A \z ) \r \n

    \s \xXX escape sequence [] [^] character list
  4. RE Literal and Language Syntax Such as escape sequence CONFLICT

    with parent language Some Languages have RE Literal AWK, Perl, Ruby, JavaScript, ...
  5. AWK

  6. Filter-oriented Programming Language $ awk 'script' srcfile $ cat srcfile

    | awk 'script' > destfile $ awk -f script srcfile
  7. Basic Syntax C-like / Shell-like ( semicolon less ) Patterns

    and Actions No need to write about stdin and split
  8. BEGIN { counting = 0 } /^$/ { counting =

    0 } counting == 1 && !/:/ { print $1 } /^GEM$/ { counting = 1 }