Skip to main content
4 of 4
formatting
Barmar
  • 10.6k
  • 1
  • 22
  • 29

Deleting extension only from the 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