首页 > 解决方案 > 如何从多个文件中删除多个第一列?

问题描述

我有多个这样的文件:

trans_ENSG00000047849.txt.traw
trans_ENSG00000047848.txt.traw
trans_ENSG00000047847.txt.traw
...

每个都有大约 300 列。列用制表符分隔。我想从每个文件中删除前 7 列。

我知道如何为每个文件执行此操作:

cut  -f 7- trans_ENSG00000047849.txt.traw > trans_ENSG00000047849.txt.trawN

有没有办法一次对所有文件执行此操作?

注意:开头有一个标签。因此,我在这里使用 cut -f 7 而不是 cut -f 8 来删除前 7 列。

标签: bashawksed

解决方案


只需使用一个for循环:

for file in *.txt.traw
do 
    cut  -f 7- "$file" > "$file"N
done

推荐阅读