Linux修改文件列名

在服务器远程操作中,通常会有修改列名的情况,手动操作比较繁琐,可使用sed函数修改列名

1.修改文件夹中的taxonomy.tsv文件夹列名并导出为biom-taxonomy.tsv文件,可使用以下函数

sed '1{ s/Feature ID/#OTUID/; s/Taxon/taxonomy/;s/Confidence/confidence/}' exported/taxonomy.tsv > biom-taxonomy.tsv

1为指定第一行 

 文件名已修改完成

2.提取文件中的几列并修改列名,输出文件

cut -f1,2 exported/taxonomy.tsv | sed '1{ s/Feature ID/#OTUID/; s/Taxon/taxonomy/}' >biom-taxonomy2.tsv

reference:

shell - Column editing and renaming of a tab-delimited table in Bash - Stack Overflowhttps://stackoverflow.com/questions/52878099/column-editing-and-renaming-of-a-tab-delimited-table-in-bash

猜你喜欢

转载自blog.csdn.net/qq_42458954/article/details/121677217
今日推荐