遍历并打印和求和列 linux

Loop through and print and sum columns linux

我想遍历 chr1-chr22 标记相同的 22 个数据集。这是一个文件的样子。 als.sumstats.meta.chr10.txt.gz。我想解压缩这些文件并从列中提取所有数据 $2、$1、$3、$9 并在新列中将 $14 和 $15 相加。我想在完成后将这些文件压缩。我想 return 附加 table 以及来自上述每一列的所有数据以供下游分析。这就是我在 zipping/unzipping 部分遇到的问题。

#!/bin/bash

FILES=/ALSsummaryGWAS/Summary_Statistics_GWAS_2016/als.sumstats.meta.chr{1..22}.txt.gz
for f in $FILES;
do
  echo "$FILES"
  echo "extracting columns 2,1,3,9"
  awk '{print ,,,, +}' > ALSGWAS.txt
done
for f in $FILES; do
  gzip -d < $f | awk '{print ,,,, +}' | tee -a all.txt | gzip > $f.sub
done