Using awk:
awk '{ for (i=1;i<=NF;i++) { if ($i ~ /num2=/) {sub(/num2=/, "", $i); $i="num2="$i-5; print} } }' file
This will loop through each column of each line looking for the column that contains num2=. When it finds that column it will:
- Remove
num2=-sub(/num2=/, "", $i) - Redefine that column as
num2={oldnum-5}-$i="num2="$i-5 - Print the line -
print