I have the following code
...
year_a=2018
year_b=2021
for (( i=year_b; i>=year_a; i-=1 )); do
printf "$i: "; grep -Eic "A-15-" <<< "$results"
done
...
Output:
2021: 0
2020: 11
2019: 0
2018: 21
I wish to make the following output:
2020: 11
2018: 21
i.e., print a year if grep gave a return output which is not equal to zero, but I don't quite understand how to build such a construction. It is necessary to execute the first command if the second has found the outcome. Maybe somebody can give me a direction, thank you.