Sh script to reduce version number in opkg status file
Since you're already using awk in there,
it would be better to rewrite all the echo - grep - sed processing with a single awk.
In particular, the entire while loop in the middle can be replaced with this:

awk -F '[:. ]' '/^Version: / {
  num1 = $3;
  num2 = $4;
  if (num1 &gt; 0) {
    gsub(num1, num1 - 1);
    print;
  } else if (num2 &gt; 0) {
    gsub(num2, num2 - 1);
    print;
  }
}
' "${BACKUP_OPKG_STATUS_FILE}" &gt;&gt; "${OPKG_STATUS_FILE}"


This produces slightly different (I think better) output than your original,
and with the number of sub-processes greatly reduced,
it's a lot more efficient.