Hello
Take this file...
Test01
Ref test
Version 01
Test02
Ref test
Version 02
Test66
Ref test
Version 66
Test99
Ref test
Version 99
I want to substitute every occurrence of Test[0-9]{2}
with a unique random number, so for example, if I was using sed
, substitution would be something like the below but obviously the below does reevaluate the random number for each occurrence of Test[0-9]{2}
num=$((1+RANDOM 20 % 60))
sed -ri "s/Test[0-9]{2}/Test${num}/" test_file
So on the execution of substitution, the file would read something like
Test59
Ref test
Version 01
Test57
Ref test
Version 02
Test48
Ref test
Version 66
Test51
Ref test
Version 99