awk to replace part of a column

dear all,
I'm trying to use Awk to eliminate the last two characters from the first column in a file. This two characters are "-1" and I need to eliminate them from each row that I have in the files. The files have two columns and look like:

ID_090-1 2
ID_3787-1 4
ID_0098-1 1
ID_12-1 4

I need to obtain something like:

ID_090 2
ID_3787 4
ID_0098 1
ID_12 4

Any help is suitable!! thank you in advance!

Hi

$ awk '{sub(/..$/,"",$1);}1' file
ID_090 2
ID_3787 4
ID_0098 1
ID_12 4

Guru.

1 Like

thank you so much guru!!!it works!!

$ awk -F'[- ]' '{print $1, $3}' a
ID_090 2
ID_3787 4
ID_0098 1
ID_12 4
1 Like
awk '{split($1,a,"-"); print a[1],$2}' file