If there is only one instance of what you want to replace, it bash(1)has an easy function first introduced in csh(1):
^old^new
will replace the first instance oldwith new:
$ filter_script file2 > output_file2
$ ^2^4
filter_script file4 > output_file2
If you want to replace all instances, this requires more input:
$ filter_script file2 > output_file2
$ !:gs/2/4/
filter_script file4 > output_file4
g . ! - , . . bash(1) Event Designators.