Using awk:
awk '{ for (i=1;i<=NF;i++) { if ($i ~ /num2=/) {sub(/num2=/, "",$4 $i); $4="num2="$4$i="num2="$i-5; print} } }' file
This removes the num2= from the 4thwill loop through each column (leaving just a number). Then re-addsof each line looking for the column that contains num2= back to the column while subtracting 5 from the number.
The problem is you have done nothing to define RANDOM TEXT so I have a feeling the column you want to work with either won't be in column 4 or won't consistently be in When it finds that column 4.it will:
- Remove
num2=-sub(/num2=/, "", $i) - Redefine that column as
num2={oldnum-5}-$i="num2="$i-5 - Print the line -
print