Using Raku (formerly known as Perl6)
raku -ne 'state $i; print .words[0]~" "; put S/^ \d**4 $/{++$i + 12000}/ given .words[1];'
Briefly, raku is called at the command line with the -ne
(linewise, non-autoprinting) flags. A state
variable is declared (once and only once), for incrementing within the code. In the second statement the .words[0]
first whitespace separated 'word' (i.e. column) is printed
followed by a ~
tilde concatenated " "
blank space (for separating the output columns). In the third statement the S///
(big-S) substitution command searches for \d**4
exactly 4 digits within given .words[1]
(the second column). A match is replaced with {++$i + 12000}
a computed value (curlies denote code blocks within regexes), and returned (because S///
big-S substitution returns the modified string).
Sample Input:
d101 11001 e101 9665 f101 9663 d102 11002 e102 11003 f102 11004 g102 11005
Sample Output:
d101 11001 e101 12001 f101 12002 d102 11002 e102 11003 f102 11004 g102 11005
https://raku.org