Entering edit mode
4.2 years ago
genomes_and_MGEs
▴
10
Hey guys,
I have a tab-delimited file like this
NZ_CP007546.1_En_asburiae4561905 434 17636
NZ_CP007546.1_En_asburiae4561905 85823 93173
NZ_CP007546.1_En_asburiae4561905 178912 203202
NZ_CP007546.1_En_asburiae4561905 313008 317041
...
I want to remove text after the last underscore on the 1st column, so that I have
NZ_CP007546.1_En 434 17636
NZ_CP007546.1_En 85823 93173
NZ_CP007546.1_En 178912 203202
NZ_CP007546.1_En 313008 317041
I know that I can use sed to do that, but when I use sed -i 's/_[^_]*$//' it removes all the text in the same line, and my goal is to do that only for the 1st column. Thanks!