Welcome to LQ
Here's something that does only that, just as a ptr towards creating your own soln
Code:
echo 'gi_49482315_ref_YP_039539.1_'|sed -E 's/_$//'
gi_49482315_ref_YP_039539.1
If eg the cols are separated by exactly one space, then you could use the 'cut' cmd to pull this out for processing.
Really we'd like to see
a) some whole recs so we can see the actual issue
b) what code have you tried so far - we prefer to help you solve this, rather than just handout solns