Sam
Sam

Reputation: 2331

Shell script hangs on awk command

This is what my script looks like essentially

        ......
        rowNum=$(awk '{print NF}' temp)
        i=1
        while [ $i -lt $rowNum ]
        do
                echo "$rowNum"
                echo "$i"
                echo "$j"
                awk -v text=$(awk -v numb=$i '{print $numb}' temp) -v num=$j 'BEGIN{FS=","} $1 ~ text {print $num}' > temp${i}
                echo "testing flag"
                i=$(expr $i + 1)
        done
        ......

When I run it I get

101
1
3

And then it just hangs with "awk * script.sh text.txt" written on the tab of the terminal continuously so it's definately just hanging on the awk command but I can't figure out how to fix it.

Thank-you

Upvotes: 1

Views: 2198

Answers (1)

wolfrevokcats
wolfrevokcats

Reputation: 2100

Looks like you didn't supply input file for awk, so it's reading stdin.

Upvotes: 6

Related Questions