Help with remove last text of a file that have specific pattern

Input file

matrix-remodelling_associated_8_
aurora_interacting_1_
L20
von_factor_A_domain_1
ATP_containing_3B_
.
.

Output file

matrix-remodelling_associated_8
aurora_interacting_1
L20
von_factor_A_domain_1
ATP_containing_3B
.
.

Command I have try:

sed 's/$_//g' input_file

The command I try is wrong :frowning:
I would like to delete the "_" if it is at the end of a text.
Thanks

Hi,

You were there. I think next command works.

$ sed 's/_$//' infile

Regards,
Birei

1 Like

Thanks ya :slight_smile:
hehe...
you're right ^^

using perl

 perl -ple 'chop if(/_$/);' inputfile
1 Like