Awk and read bailing out

Hi All,

Can some body help me in this to work

#!/bin/ksh

    nof=`wc -l outFile_R.out | sed -e 's/[a-zA-Z_. ]*//g' `
    no_of_lines=`expr $nof - 0`
    z=1
    while [[ $z -le $no_of_lines ]]
    do
    cat outFile_R.out | awk -v I="$z" 'NR==I { print $0 }' | read from_date to_date id
    echo "executing $from_date $to_date $id"
    z=$((z + 1))
    done
    

output required if no_of_lines = 2

executing 2010-01-01 2010-01-31 1
executing 2010-01-01 2010-01-31 2

---------- Post updated at 02:14 PM ---------- Previous update was at 02:09 PM ----------

got it working using nawk :slight_smile:

Hi sol_nov,

I noticed it may be possible to further simplify your script to something like this.

while read from_date to_date id
do
  echo "executing $from_date $to_date $id"
done < outFile_R.out

Perhaps that could be of use to you...

:smiley:

On Solaris it's generally better to use /usr/xpg4/bin/awk or nawk and not /usr/bin/awk