Skip to main content
2 of 4
added 31 characters in body
Roli
  • 213
  • 1
  • 4
  • 12

deleting extension from only first column

I have a file like this with tab separated two columns:

ENSG00000242268.2 0.07563 ENSG00000270112.3 0.09976 ENSG00000167578.15 4.38608 ENSG00000273842.1 0.0 ENSG00000078237.5 4.08856

I would like to remove the numeric extensions from the end in the 1st column, so the output will be:

ENSG00000242268 0.07563 ENSG00000270112 0.09976 ENSG00000167578 4.38608 ENSG00000273842 0.0 ENSG00000078237 4.08856

Simply doing sed 's/..*$//' returns only first column value and using awk with field separator '.' awk -F'.' removes the values from second column too as there are decimal numbers.

A similar question has been answered here: removing extensions in a column

I am still not being able to delete just from column 1st only.

Roli
  • 213
  • 1
  • 4
  • 12