Solved

# Scripting a ksh script to read in a value and take action if that value is true.

Posted on 2004-10-11

I need a script that basically compares the value out of a text file and compares it to a value list. If it meets the value, then it needs to replace the next value with the current value in the text file. I have started the script as below, but I am having problems with it working right. Please help. Since I am fairly new at shell scripting, any suggestions would be greatly appreciated. I do only prefer to use korn shell.

#!/bin/ksh

set -A array

array[1]="20041010"

array[2]="20041011"

array[3]="20041012"

array[4]="20041013"

array[5]="MH2004MAY"

if [ "${array[1]}" -eq "cut -c 81-89 gl265test" ] ; then

sed 's/${array[1]},${array[2]}/' gl265test > gl265.out

fi

if [ "${array[2]}" -eq "cut -c 81-89 gl265test" ] ; then

sed 's/${array[2]},${array[3]}/' gl265test > gl265.out

fi

if [ "${array[3]}" -eq "cut -c 81-89 gl265test" ] ; then

sed 's/${array[3]},${array[4]}/' gl265test > gl265.out

fi

if [ "${array[4]}" -eq "cut -c 81-89 gl265test" ] ; then

sed 's/${array[4]},${array[5]}/' gl265test > gl265.out

fi

if [ "${array[5]}" -eq "cut -c 81-89 gl265test" ] ; then

sed 's/${array[5]},${array[1]}/' gl265test > gl265.out

fi