I have many pairs of integers like (a,b),(c,d),(e,f) .. so on. I need to check if the value of 1st element lies between a range of 90% to 150% of the 2nd element and print the value as Pass.
The values (a,b) are from different columns of a file for two different times respectively.
File1:1 12 123 1234-text-1 12345
File2:2 23 234 1239-text-1 12347
a="$(find . -name *abc.gz* -mtime 1 | xargs zcat | awk -F"," '{print $4}' | grep "text-1" | awk '{$1=$1;print}' | awk '{print $1}')"
b="$(find . -name *abc.gz* -mtime 10 | xargs zcat | awk -F"," '{print $4}' | | grep "text-1"| awk '{$1=$1;print}' | awk '{print $1}')"
#a=1234
#b=1239
b1="$(bc <<<"${b}*9/10")"
b2="$(bc <<<"${b}*15/10")"
if [ ${a} -ge ${b1} -a ${a} -le ${b2} ];
then
echo "PASS"
else
echo "FAIL"
fi
I need to do it for different text values like 'text-2', 'text-3' etc for different columns of a file $5, $6 etc.
cut
instead ofawk
. Also, since you need to spawn so many processes for this simple task, you might consider writing the whole program in a more efficient programming language, such as Perl, Ruby or Python.$1=$1
is a no-op: You just assign the first field to itself. What's the purpose of this?