#!/bin/bash input="../mostUsedP.txt" while IFS= read -r line do p=`xzcat in.tsv.xz | paste expected.tsv - |grep "P.* $line" | wc -l` s=`xzcat in.tsv.xz | paste expected.tsv - |grep "S.* $line" | wc -l` diff=$((p-s)) if [ $p -ge $s ] then echo "$line, $diff" fi done < "$input"