From Chocolate Motmot, 3 Years ago, written in Plain Text.
Embed
  1. #!/bin/bash
  2.  
  3. filename='data.txt'
  4.  
  5. declare -a arr
  6.  
  7. n=0
  8. while read line; do
  9.     arr[$n]=$line
  10.     n=$((n+1))
  11. done < $filename
  12. arr[$n]=$line
  13.  
  14. counter=0
  15. len=${#arr[@]}
  16. for (( index=3; index<$len; index++ )); do
  17.     if [[ ${arr[$index]}>${arr[$index-3]} ]]; then
  18.         counter=$((counter+1))
  19.     fi
  20. done
  21.  
  22. echo $counter
captcha