I have some files in the format
Y15-SUB-B04-P17-BK_M02734_4_000000000-ANNUF_1_1111_24724_4878;size=1;
Y15-SUB-B05-P22-LM_M02734_4_000000000-ANNUF_1_1111_20624_14973;size=1;
Y15-SUB-B05-P22-LM_M02734_4_000000000-ANNUF_1_1103_11326_10379;size=1;
I wish to replace every occurrence of the underscore (_) with a colon (:) EXCEPT for the first one. I want an output like this:
Y15-SUB-B04-P17-BK_M02734:4:000000000-ANNUF:1:1111:24724:4878;size=1;
Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1111:20624:14973;size=1;
Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1103:11326:10379;size=1;
I know I can use sed -i '' 's/_/:/g' old_file
to replace ALL (or sed 's/_/:/g' old_file > new_file
), and that I could add numbers to replace only the 2nd, 4th or so occurrence:
sed 's/_/:/2' old_file > new_file
But how to replace every occurrence on each line BUT the first?