Change a column name according to the file name
1
0
Entering edit mode
3.6 years ago
dpc ▴ 240

I have around 52 files named like: ERR260147.genefamilies.tsv, ERR260158.genefamilies.tsv ERR275198.genefamilies.tsv, etc and each file has two columns. I want to change the second column name of each file according to the name of the file. For example, the second column name for file ERR260147.genefamilies.tsv will be named like ERR260147_Abundance-RPKs and for ERR275198.genefamilies.tsv will be ERR275198_Abundance-RPKs. Please note, part of a column name will come from the file name and a constant "_Abundance-RPKs".

Can anyone please help me.

thanks, dpc

bash • 672 views
ADD COMMENT
1
Entering edit mode
3.6 years ago
Ram 43k

Use awk. You'll need the variables NR, $2 and FILENAME and the function gsub. Google these and use them to assemble a mini-pipeline. This is a good learning exercise.

ADD COMMENT

Login before adding your answer.

Traffic: 1765 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6