1*e6d6c189SCody Peter Mello#!/bin/bash 2*e6d6c189SCody Peter Mello 3*e6d6c189SCody Peter Melloif [[ -z "$AWK" || -z "$WORKDIR" ]]; then 4*e6d6c189SCody Peter Mello printf '$AWK and $WORKDIR must be set\n' >&2 5*e6d6c189SCody Peter Mello exit 1 6*e6d6c189SCody Peter Mellofi 7*e6d6c189SCody Peter Mello 8*e6d6c189SCody Peter MelloTEMP1=$WORKDIR/test.temp.1 9*e6d6c189SCody Peter MelloTEMP2=$WORKDIR/test.temp.2 10*e6d6c189SCody Peter MelloTEMP3=$WORKDIR/test.temp.3 11*e6d6c189SCody Peter Mello 12*e6d6c189SCody Peter Mello# This is a demo of different ways of printing with gawk. Try it 13*e6d6c189SCody Peter Mello# with and without -c (compatibility) flag, redirecting output 14*e6d6c189SCody Peter Mello# from gawk to a file or not. Some results can be quite unexpected. 15*e6d6c189SCody Peter Mello$AWK 'BEGIN { 16*e6d6c189SCody Peter Mello print "Goes to a file out1" > "'$TEMP1'" 17*e6d6c189SCody Peter Mello print "Normal print statement" 18*e6d6c189SCody Peter Mello print "This printed on stdout" > "/dev/stdout" 19*e6d6c189SCody Peter Mello print "You blew it!" > "/dev/stderr" 20*e6d6c189SCody Peter Mello}' > $TEMP2 2> $TEMP3 21*e6d6c189SCody Peter Mello 22*e6d6c189SCody Peter Mellodiff out1.ok $TEMP1 \ 23*e6d6c189SCody Peter Mello && diff out2.ok $TEMP2 \ 24*e6d6c189SCody Peter Mello && diff out3.ok $TEMP3 \ 25*e6d6c189SCody Peter Mello && rm -f $TEMP1 $TEMP2 $TEMP3 26