I have code in which I need to do a mass find and replace (within only one file).I could easily do this except for that I need a free program (Preferably already compiled for Ubuntu so I don't have to compile it myself) that can add a number to  each one similar to the program bulk rename except within a text file.So for example, I need to do the following with over a hundred items:Turn:begin();Random code in between.begin();More random code...100 more begin()s...begin();Into:begin(1);Random code in between.begin(2);More random code.100 more begin()s...begin(102);And if anyone knows of a program that only works with windows, that would be fine, as well.Any help is greatly appreciated.
Advanced Find and Replace Program
text processing
perl -pe 's/begin\(/$&. ++$n/ge' < input-fileOr for in-place editing (that is replace the file with the modified copy of itself):perl -pi.back -e 's/begin\(/$&. ++$n/ge' input-and-output-file(remove the .back if you're feeling adventurous and don't need a backup).The above replaces ever begin( with the same ($&) with the incremented value of the $n variable (++$n) appended (.).If you want to replace begin() instead of begin(:perl -pe 's/begin\(\K\)/++$n.)/ge' < input-file