Artificial intelligent assistant

Replace pattern between two characters Staphylococcus_sp_HMSC14C01-KV792037.1:0.00371647154267842634,Staphylococcus_hominis_VCU122-AHLD01000058.1:0.00124439639436691308)69:0.00227646100249620856,(Staphylococcus_sp_HMSC072E01-KV814990.1:0.00288325234399461859,(((Staphylococcus_hominis_793_SHAE-JUSR01000051.1:0.00594391769091206796,Staphylococcus_pettenkoferi_1286_SHAE-JVVL01000037.1:0.00594050248317441135) The comma is separating different items and in each item I want to remove everything between `-` and `:` including `-` but keeping `:`. How can I do that? So it should look like: Staphylococcus_sp_HMSC14C01:0.00371647154267842634,Staphylococcus_hominis_VCU122:0.00124439639436691308)69:0.00227646100249620856 I used `sed 's/-.*://' 1.file > 2.file` but ended up removing the whole file and just kept the first and last values.

`.*` is a greedy regexp, matching the _longest_ possible match. You need to match the shortest match but match it globally on the whole line. Try

`sed 's/-[^:-]*:/:/g' 1.file > 2.file`

The character class `[^:-]` matches anything _except_ colon and dash (and maybe it should match anything except colon only), so the regexp says "dash followed by any number of non-dash, non-colon characters followed by a colon". It then replaces that with a colon (since you wanted to keep that) and does the replacement globally (the trailing `g`) on the line. If you omit the `g`, only the first instance would be replaced.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 73e914a78e01dec523a85aed6340fa94