Suppose i have this code
---
bcc L_BRS_($4593)_($455E)
nop
nop
nop
L_BRS_($4593)_($455E)
bcc L_BRS_($4594)_($455F)
nop
nop
nop
L_BRS_($4594)_($455F)
---
I want to replace "L_BRS_($4593)_($455E)" with "lbrs001" (bot in single line and where line start with "bcc") and same with other "L_BRS".
At the end the code should look like:
---
bcc lbrs001
nop
nop
nop
lbrs001
bcc lbrs002
nop
nop
nop
lbrs002
---
I also need that the script "autodetect" the values between brachets of "L_BRS_($4593)_($455E)" and change all other of them in all text with the same value.
So "L_BRS_($4593)_($455E)" becomes lbrs001 in all text,
"L_BRS_($4594)_($455f) brcomes lbrs002 in all text... an so on.
Whit this:
awk 'BEGIN { rval=1000 } /L_BRS_/{gsub(/L_BRS_(.*)_(.*)/,"lbrs"rval,$0); rval++;} {print $0}' test.txt
i achieve this:
---
bcc lbrs1000
nop
nop
nop
lbrs1001
bcc lbrs1002
nop
nop
nop
bcc lbrs1000
nop
nop
nop
lbrs1001
bcc lbrs1002
nop
nop
nop
lbrs1003
lbrs1003
---
but isn't what i mean.
"1000" and "1001" should be the same.
"1002" and "1003" should be "1000"+1 and the same.
Someone can help me?
---
bcc L_BRS_($4593)_($455E)
nop
nop
nop
L_BRS_($4593)_($455E)
bcc L_BRS_($4594)_($455F)
nop
nop
nop
L_BRS_($4594)_($455F)
---
I want to replace "L_BRS_($4593)_($455E)" with "lbrs001" (bot in single line and where line start with "bcc") and same with other "L_BRS".
At the end the code should look like:
---
bcc lbrs001
nop
nop
nop
lbrs001
bcc lbrs002
nop
nop
nop
lbrs002
---
I also need that the script "autodetect" the values between brachets of "L_BRS_($4593)_($455E)" and change all other of them in all text with the same value.
So "L_BRS_($4593)_($455E)" becomes lbrs001 in all text,
"L_BRS_($4594)_($455f) brcomes lbrs002 in all text... an so on.
Whit this:
awk 'BEGIN { rval=1000 } /L_BRS_/{gsub(/L_BRS_(.*)_(.*)/,"lbrs"rval,$0); rval++;} {print $0}' test.txt
i achieve this:
---
bcc lbrs1000
nop
nop
nop
lbrs1001
bcc lbrs1002
nop
nop
nop
bcc lbrs1000
nop
nop
nop
lbrs1001
bcc lbrs1002
nop
nop
nop
lbrs1003
lbrs1003
---
but isn't what i mean.
"1000" and "1001" should be the same.
"1002" and "1003" should be "1000"+1 and the same.
Someone can help me?