# Meek, awk BEGIN{print int((ARGV[1]-ARGV[2]+1)/(ARGV[3]-ARGV[4]+1)*(ARGV[1]/ARGV[2])+1)} Just a starting point, using all the numbers. Has to be called like this awk -f meek.awk arg1 arg2 arg3 arg4