在我的Shell脚本中运行嵌套循环时遇到问题

时间:2020-05-30 10:58:45

标签: linux eof

为Shellscript提供标签:

#!/bin/bash
#SBATCH -N 1
#SBATCH -t 00:05:00

为LDSC数据集运行bash脚本

加载模块

module load 2019
module load Python/2.7.15-foss-2019b

将文件复制到临时页面

cp -r $HOME/ldsc/eur_w_ld_chr $TMPDIR

cp $HOME/output_dir/*_txt.sumstats.gz $TMPDIR

cp $HOME/output_dir/*_Jan23.tbl.sumstats.gz $TMPDIR

myLDSC=$HOME/ldsc/ldsc.py

cd $TMPDIR 

#create output dir
mkdir -p "$TMPDIR"/output_dir

ncors=15
for f in $(ls *.txt.sumstats.gz);do 
    for i in $(ls *_Jan23.tbl.sumstats.gz);do
((k=k%ncors)); ((k++==0)) && wait
{
#take .gz of files
ff=$(echo ${f} | sed 's/\.gz//') 
ii=$(echo ${i} | sed 's/\.gz//')
fff=$(echo ${ff} | sed 's/\munged_Summary_statistics_MAGNETIC_//')
iii=$(echo ${ii} | sed 's/\Munged_ENIGMA2_//')

#unzip files
gunzip ${f} 
gunzip ${i}

#call object with arguments

$myLDSC --rg ${ff},${ii} --out output_dir/LDSC_"${fff}"_"${iii}" --ref-ld-chr eur_w_ld_chr/ --w-ld-chr eur_w_ld_chr/
#surely this is the part where it's going wrong
} & 
done 
wait

#copy output dir from scratch to home
cp -r "$TMPDIR"/output_dir $HOME

问题似乎在代码的最后一行出现,循环似乎未正确关闭,我得到的错误是文件结束错误(EOF)。

0 个答案:

没有答案
相关问题