# find line starting with modulus: # while read line do if [ "$line" = "modulus:" ]; then break fi done # extract modulus, up to line starting with publicExponent: # n="" while read word rest do if [ "$word" = "publicExponent:" ]; then break; fi n="$n$word" done echo "n = $n" # debug # n=$(echo "$n" | tr ... # remove non-alphanumeric chars