8 later thoughts
sed can be used to replace regex-defined sections of text in a file with random number like this.
The solution in the answer linked utilizes the concepts of “hold space” and “pattern space” in sed. This answer goes over them in detail.
4 earlier thoughts
ctrl + enter
alt + enter