Skip to main content
2 of 2
deleted 14 characters in body
jesse_b
  • 41.5k
  • 14
  • 108
  • 162

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:

  1. Remove num2= - sub(/num2=/, "", $i)
  2. Redefine that column as num2={oldnum-5} - $i="num2="$i-5
  3. Print the line - print
jesse_b
  • 41.5k
  • 14
  • 108
  • 162