I am trying to run the first awk script in O'Reilly's Sed and Awk, using a .bat file instead of Unix shell script. The script only works if it is on a single line in the .bat file.
Original unix script:
gawk -F, '{
print $4 \", \" $0
}' $* |
sort | gawk -F, '$1==LastState{
print \"\t\" $2
}
$1!=LastState {
LastState=$1
print $1
print \"\t\" $2
}'
My script that works, but only on one line:
gawk -F, "{ print $4 \", \" $0}" |sort | gawk -F, "$1==LastState{print \"\t\" $2;} $1!=LastState {LastState=$1; print $1; print \"\t\" $2;}"
Called with:
C:> sed -f namestate list | script2
I have sed, awk, and sort installed as separate .exe's.
This is driving me crazy trying to fix this.
Original unix script:
gawk -F, '{
print $4 \", \" $0
}' $* |
sort | gawk -F, '$1==LastState{
print \"\t\" $2
}
$1!=LastState {
LastState=$1
print $1
print \"\t\" $2
}'
My script that works, but only on one line:
gawk -F, "{ print $4 \", \" $0}" |sort | gawk -F, "$1==LastState{print \"\t\" $2;} $1!=LastState {LastState=$1; print $1; print \"\t\" $2;}"
Called with:
C:> sed -f namestate list | script2
I have sed, awk, and sort installed as separate .exe's.
This is driving me crazy trying to fix this.