I need to replace instances of `Progress (n,m)` and `Progress label="some text title" (n,m)` in a scripting language with new values `(N,M)` where

```
N= integer ((n/m) * normal)
M= integer ( normal )

```

The progress statement can be anywhere on the script line (and worse, though not with current scripts, split across lines).

The value `normal` is a specified number between 1 and 255, and `n` and `m` are floating point numbers

So far, my `sed` implementation is below. It only works on `Progress (n,m)` formats and not `Progress label="Title" (n,m)` formats, *but its just plain nuts*:

```
#!/bin/bash
normal=$1; 
file=$2
for n in $(sed -rn '/Progress/s/Progress[ \t]+\(([0-9\. \t]+),([0-9\. \t]+)\).+/\1/p' "$file" )
do 
    m=$(sed -rn "/Progress/s/Progress[ \t]+\(${n},([0-9\. \t]+).+/\1/p" "$file")
    N=$(echo "($normal * $n)/$m" | bc)
    M=$normal
    sed -ri "/Progress/s/Progress[ \t]+\($n,$m\)/Progress ($N,$M)/" "$file"
done

```

Simply put: **This works, but, is there a better way?**

My toolbox has `sed` and `bash` scripting in it, and not so much `perl`, `awk` and the like which I think this problem is more suited to.

**Edit** Sample input.

```
Progress label="qt-xx-95" (0, 50) thermal label "qt-xx-95" ramp(slew=.75,sp=95,closed) Progress (20, 50) Pause  5 Progress (25, 50) Pause  5 Progress (30, 50) Pause  5 Progress (35, 50) Pause  5 Progress (40, 50) Pause  5 Progress (45, 50) Pause  5 Progress (50, 50)
Progress label="qt-95-70" (0, 40) thermal label "qt-95-70" hold(sp=70)        Progress (10, 40) Pause  5 Progress (15, 40) Pause  5 Progress (20, 40) Pause  5 Progress (25, 40) Pause  5 

```