#! /bin/sh while read a b c do echo "a = $a, b = $b, c = $c" # if true # if test "$a" = "pie" if [ "$a" = "pie" ] then echo "got pie"; exit fi done # sample run: # $ printf "1 2 3 4 5\nz yy xxx bb\npie 34 56\n" | bash y.sh # a = 1, b = 2, c = 3 4 5 # a = z, b = yy, c = xxx bb # a = pie, b = 34, c = 56 # got pie # $