I have a file with multiple lines like below, I need to check on column starting with #prototype if it has the .Number.txt extension do nothing else add 1.txt extension.
Source data
Jdbc_app_data :- sample data
#prototype= sample data from test.1.txt
application_id=122135
#prototype= sample data from test.2.txt
target_id=354
#prototype= sample data from test.txt
system_id=222
#prototype= sample data from test.txt
Target Data
Jdbc_app_data :- sample data
#prototype= sample data from test.1.txt
application_id=122135
#prototype= sample data from test.2.txt
target_id=354
#prototype= sample data from test.1.txt
system_id=222
#prototype= sample data from test.1.txt
@ctsgnb: your code will not work if the file doesn't have 't' as last char before extension:
$ cat input
Source data
Jdbc_app_data :- sample data
#prototype= sample data from test.1.txt
application_id=122135
#prototype= sample data from test.2.txt
target_id=354
#prototype= sample data from testhh.txt
system_id=222
#prototype= sample data from testff.txt
$ sed '/^#prot/s/t\.t/t.1.t/' input
Source data
Jdbc_app_data :- sample data
#prototype= sample data from test.1.txt
application_id=122135
#prototype= sample data from test.2.txt
target_id=354
#prototype= sample data from testhh.txt
system_id=222
#prototype= sample data from testff.txt
More general:
sed '/^#prototype/ s/\([^\d]\).txt/\1\.1\.txt/' input
will insert '.1' for a filename with a character other than digit ([^\d]) before '.txt'