#!/bin/bash maxint=9223372036854775807 root=3037000499 destination=4294967295 rm -f prime.list SECONDS=0 n=0 echo "Counting number of primes..." size=$(cat source.list | wc -l) echo "00000001 1" >> prime.list while read -r prime; do hex=$(printf "%08X" "${prime:0:-1}") echo "$hex $prime" >> prime.list if [[ $((n%100)) == 0 ]]; then clear rate=$((SECONDS*1000000/(n+1))) estsec=$((rate*size/1000000)) remsec=$((estsec-SECONDS)) echo "Running Time: $((SECONDS/86400)) days, $(((SECONDS%86400)/3600)) hours, $(((SECONDS%3600)/60)) minutes and $(((SECONDS%60))) seconds..." echo "Remaining Time: $((remsec/86400)) days, $(((remsec%86400)/3600)) hours, $(((remsec%3600)/60)) minutes and $(((remsec%60))) seconds..." echo "Processed $n of $size PRIME numbers at an average rate of $((n/(SECONDS+1))) per second..." echo "Latest Prime Number: $prime" echo "Destination Number: $destination [$((n*100/size)) %]" fi ((n++)) done < source.list