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

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 • 759 views
ADD COMMENT
1
Entering edit mode
4.2 years ago
Ram 44k

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: 1883 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