#!/bin/bash
#
# Code by  venkentom@gmail.com
#
# Licenced by the GPL General Public License
# Have a look at:
# http://www.gnu.org/copyleft/gpl.html
# For more information about the GPL License
#
# I am not responsible for what this code does to your hw/sw/mind
# Use at your own risk
#
# Usage: for i in `ls | grep xvg`; sh occupancy_xvg.sh $i; done
#



file=$1 #pass file as input!
VALUE=0

let COUNTER=0 #counts the number of instances above threshold
let INT=0 #number the measure amount of data points
while read -r -a line ; do
    VALUE=${line[1]} 
#    echo $VALUE
    if (( $VALUE > 0 )); then #define threshold
	let COUNTER=COUNTER+1 #count this
#        echo $COUNTER
    fi
    let INT=INT+1 #count this too

done < $file #hydro_r001-pep.xvg

if (( $COUNTER > 0)); then
echo -ne "$file "
echo "$COUNTER $INT" | awk '{printf "%.2f \n", $1/$2*100}'
fi

