I have a file that has some missing data point's value and the missing value are shown as ****
. I need to select rows having consecutive 7 columns with value less than 10. When I run my script it also gives those rows that have ****
in consecutive columns.
I can solve it easily by replacing all ****
with a higher value. But, I don't want to change my input file. I want to do something so that my script treat ****
as a number(greater than 10 i.e. str=****=100
). How can I do that?
sample input consecutive7pointDown10.input
-
2 3 4 5 6 7 8 0 12 14 23
2 3 4 12 6 7 8 0 1 2 23
**** **** **** **** **** **** **** 8 **** **** 12
My script's result consecutive7pointDown10.output
-
2 3 4 5 6 7 8 0 12 14 23
**** **** **** **** **** **** **** 8 **** **** 12
But, expected output
2 3 4 5 6 7 8 0 12 14 23
My script consecutive7pointDown10
is as follows-
#!/bin/bash
########################################################################################################################
# This script results rows having at most 10°C in consecutive at most 7 points.
# input = scriptname.input
# output = scriptname.output
########################################################################################################################
input=`basename "$0"`.input
output=`basename "$0"`.output
awk '{
for(i=4;i<=34-6;i++)
{
if($i<=10 && $(i+1)<=10 && $(i+2)<=10 && $(i+3)<=10 && $(i+4)<=10 && $(i+5)<=10 && $(i+6)<=10)
{
print
next
}
}
}' $input > $output
****
? or is there a case where such lines can still have 7 consecutive columns less than 10 and you want that in output? – Sundeep Oct 23 '17 at 15:38gsub(/\*{4}/,100)
before the for-loop – Sundeep Oct 23 '17 at 15:42