Scripts and Utilities -- Awk lecture links


  • Jim Plank
  • Directory: /home/cs494/notes/Awk
  • This file: http://www.cs.utk.edu/~plank/plank/classes/cs494/494/notes/Awk/links.html
  • The lecture notes: http://www.cs.utk.edu/~plank/plank/classes/cs494/494/notes/Awk/lecture.html

    setup

    Simple pattern-action statements

    Awkgrep
    Input
    awkgrep input
    awkgrep < input
    
    awk '{ print $1, $NF }' input
    
    cat awkgrep2
    awkgrep2 input
    

    Printf

    awkrev
    awkrev input
    

    Type casting

    awkcast
    echo "4 Jim" | awkcast
    

    BEGIN and END

    awkwc
    awkwc awkwc
    wc awkwc
    

    next and exit

    awkpo
    cat -n input
    cat -n input | awkpo
    
    awkptR
    awkptR input
    

    Arrays

    usopen, masters, kemper, memorial.
    awkgolf.
    awkgolf kemper
    cat masters usopen kemper memorial | awkgolf
    

    File indirection

    awk '{print $0 > "f1"}' < input
    cat f1
    

    Multiline awk scripts in the Bourne shell

    shwc
    awkwc awkwc
    shwc awkwc
    shwc < awkwc
    

    Bad string processing

    sp.awk
    awk -f sp.awk input