i need a code that would, trigger a set of instructions(if-then condition) .. based on the situation like .. if any of the rows in H5,H4,H3 .. but not H1,H2 has a value greater than 1.
What exactly are you trying to do? - building a pile of if-then-else constructs is possible in awk in a very simple way. Huge blocks of if-then-else are prone to errors as well
You could use sed to delete heading line and then read columns into an Array. Remember bash arrays are indexed from zero, so H[0] is column 1, H[5] is column 6:
#!/bin/bash
IFS=,
sed '1d' infile | while read -a H
do
if [ ${H[0]} -le 1 -a ${H[1]} -le 1 ] &&
[ ${H[4]} -gt 1 -o ${H[3]} -gt 1 -o ${H[2]} -gt 1 ]
then
echo "set of instructions"
fi
done
IFS=$' \t\n'
the sample file looks like this .. there are 18 columns in total, out of which last 3 are amount columns(D1 D2 D3), having certain values.. nothing has to be changed in the file .. the requirement is to read the last 3 columns of the file and in case any row has a value greater than '1' .. in that case 'a set of instructions' have to be executed..
thanks for the quick response vipin, one last question though , how to introduce an else in here .. lets suppose the amounts are less than '1' .. a different set of instructions should be executed