I have multiple files which look like this:
trans_ENSG00000047849.txt.traw
trans_ENSG00000047848.txt.traw
trans_ENSG00000047847.txt.traw
...
In them I have around 300 columns, and column names look like this:
NA20826_NA20826 NA20828_NA20828 NA20819_NA20819
I would like that my column names in all files have instead this form:
NA20826 NA20828 NA20819
In other words I would like to remove everything after underscore _ in every column name and in every file.
I should mention that there is a here is a tab space at the beginning of each file.
I tried this:
sed -ri 's/[_].*$//' trans_*.txt.traw
but when I tried to open one of these transformed files in R I got this error:
> e=read.table("trans_ENSG00000135541.txt.traw", header=TRUE)
Error in read.table("trans_ENSG00000135541.txt.traw", header = TRUE) :
more columns than column names