Quote:
Originally Posted by
namishtiwari
lorcan,
thanks for the input.
when i ran the script it is telling
./testingscript testingdata
Check the 1 field of the INPUT FILE
it is not incrementing the COUNT value so it is printing only a single record at a time.
You mentioned ---
This script checks for the 15 tickets in a row and also checks if there are 5 tickets within every 9 columns.
And as a whole i am checking whether there are atleast one ticket in a column and arranged in ascending order.
The first one you mentioned is perfectly fine.
the second line is somewhat like this--
00,11,21,00,00,55,00,73,83,07,00,22,39,43,00,66,00,00,00,15,00,00,44,58,67,00,87
this is one data in a file,it consists of 3 rows and 9 columns.we can break
00,11,21,00,00,55,00,73,83
07,00,22,39,43,00,66,00,00
00,15,00,00,44,58,67,00,87
We need to check in this that each column should have min 1 value and if more than that then it should be in ascending order not as a whole.
Thanks for your kind help.
/* Error messages ;
“COL”i”FNW”=Column numberx Total Field amount less than 1 or more than 2
“COL””i”NA” =Column numberx Not ascending
“RW1NA”=Row1 not ascending
“R1FN5 " = Row1 Total field amount is less or more than 5
*/
/*NR is line number of inputfile */
Try this code ;
cat inputfile | awk -F',' '{
last1=0;last2=0;last3=0;i=0;k=0;l=0;m=0;msg="";r1=0;r2=0;r3=0;
while ( i < 9 )
{
i++;n=0;
if ( $i != 0 )
{
n++;k++;
if ( $i > last1 ) {last1=$i}else { r1=1}};
if ( $(i+9) != 0 )
{
n++;l++;
if ( $(i+9) > last2 ) {last2=$(i+9)}else { r2=1 }};
if ( $(i+18) != 0 )
{
n++;m++;
if ( $(i+18) > last3 ) {last3=$(i+18)}else { r3=1 }};
if ( n < 1 )
{ msg=msg"COL"i"FNW " }
else
{
if (( $i != 0 ) && ( $(i+9) != 0 ) && ( $(i+9) < $i )){msg=msg"COL"i"NA "}
else {
if (( $i != 0 ) && ( $(i+18) != 0 ) && ( $(i+18) < $i )){msg=msg"COL"i"NA "}
else {
if (( $(i+9) != 0 ) && ( $(i+18) != 0 ) && ( $(i+18) < $(i+9) )){msg=msg"COL"i
"NA " }
else {
if ((( $i != 0 ) && ( $(i+9) != 0 ) && ( $(i+18) != 0 )) && ( ( $i > $(i+9) )
|| ( $i > $(i+18) ) || ( $(i+9) > $ (i+18) ) )) { msg=msg"COL"i"NA " } ;}}}}};
if ( r1 != 0 ) {msg=msg"RW1NA "};
if ( r2 != 0 ) {msg=msg"RW2NA "};
if ( r3 != 0 ) {msg=msg"RW3NA "};
if ( k != 5 ) {msg=msg"R1FN5 "};
if ( l != 5 ) {msg=msg"R2FN5 "};
if ( m != 5 ) {msg=msg"R3FN5 "};
if ( msg != "" ) {printf ( "%d " "%s" "\n",NR,msg)};
}'