我有一個循環問題,第一個for循環(d)沒有迭代到它的下一個指示值(1)。任何想法,我做錯了什麼?我試過使用continue命令來「手動」強制for循環迭代到它的下一個值,但那沒有奏效。從本質上講,每次運行代碼時,它都會完成for循環的(0)迭代,但隨後停止在終端中而不顯示任何錯誤消息。我簡化了第二個嵌套for循環,以便它只有一個值(0)以便壓縮代碼。提前致謝!for循環shell腳本不迭代
#!/bin/bash
# PRSice Commands
dates=$(date +"%m_%d_%Y")
cd /media/sf_Completed_PRS/
mkdir PRS_$dates
echo "Name of input (target) data set: "
read targetname
cd /media/sf_VMShare/
mv $targetname.bim /home/brainlab/
mv $targetname.fam /home/brainlab/
mv $targetname.bed /home/brainlab/
for d in 0 1 2
do
if [ $d = 0 ]; then
gwas=mddgwas.assoc
gwasn=MDD
fi
if [ $d = 1 ]; then
gwas=scz2.assoc
gwasn=SCZ2
fi
if [ $d = 2 ]; then
gwas=BIP.assoc
gwasn=BIP
fi
cd /media/sf_Completed_PRS/PRS_$dates/
directory=$gwasn
mkdir $directory
for t in 0
do
if [ $t = 0 ]; then
lower=.0001
inc=.0009
upper=.001
fi
if [ $t = 1 ]; then
break
fi
cd /home/brainlab
R --file=PRSice_v1.25.R -q --args \
base $gwas \
target $targetname \
slower $lower \
supper $upper \
sinc $inc \
clump.p1 1 \
clump.p2 1 \
clump.r2 0.1 \
clumb.kb 500 \
no.regression T \
plink ./plink_1.9_linux_160914 \
figname compare_1\
cd /home/brainlab
if [ $t = 0 ]; then
mv PROFILES.0.0001.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.0010.profile /media/sf_Completed_PRS/PRS_$dates/$directory
fi
if [ $t = 1 ]; then
mv PROFILES.0.01.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.05.profile /media/sf_Completed_PRS/PRS_$dates/$directory
fi
if [ $t = 2 ]; then
mv PROFILES.0.1.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.2.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.3.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.4.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.0.5.profile /media/sf_Completed_PRS/PRS_$dates/$directory
fi
if [ $t = 3 ]; then
mv PROFILES.1.profile /media/sf_Completed_PRS/PRS_$dates/$directory
mv PROFILES.2.profile /media/sf_Completed_PRS/PRS_$dates/$directory
fi
done
cd /media/sf_Completed_PRS/PRS_$dates/$directory
sed 's/SCORE/SCORE-0.0001/' PROFILES.0.0001.profile > new_file && mv new_file PROFILES.0.0001.profile
sed 's/SCORE/SCORE-0.0010/' PROFILES.0.0010.profile > new_file && mv new_file PROFILES.0.0010.profile
sed 's/SCORE/SCORE-0.01/' PROFILES.0.01.profile > new_file && mv new_file PROFILES.0.01.profile
sed 's/SCORE/SCORE-0.05/' PROFILES.0.05.profile > new_file && mv new_file PROFILES.0.05.profile
sed 's/SCORE/SCORE-0.1/' PROFILES.0.1.profile > new_file && mv new_file PROFILES.0.1.profile
sed 's/SCORE/SCORE-0.2/' PROFILES.0.2.profile > new_file && mv new_file PROFILES.0.2.profile
sed 's/SCORE/SCORE-0.3/' PROFILES.0.3.profile > new_file && mv new_file PROFILES.0.3.profile
sed 's/SCORE/SCORE-0.4/' PROFILES.0.4.profile > new_file && mv new_file PROFILES.0.4.profile
sed 's/SCORE/SCORE-0.5/' PROFILES.0.5.profile > new_file && mv new_file PROFILES.0.5.profile
sed 's/SCORE/SCORE-1/' PROFILES.1.profile > new_file && mv new_file PROFILES.1.profile
sed 's/SCORE/SCORE-2/' PROFILES.2.profile > new_file && mv new_file PROFILES.2.profile
cat > compiledScores$gwasn
awk '{print $1,$2,$6}' PROFILES.0.0001.profile > compiledScores$gwasn
awk '{print $6}' PROFILES.0.0010.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.01.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.05.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.1.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.2.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.3.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.4.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.0.5.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
awk '{print $6}' PROFILES.1.profile > tempfile.txt
pr -m -t -J compiledScores$gwasn tempfile.txt > new_file && mv new_file compiledScores$gwasn
column -t compiledScores$gwasn > new_file && mv new_file compiledScores$gwasn
done
很難找到沒有縮進的每個for的'done'。 – Kaz
https://en.wikipedia.org/wiki/Stray_Cat_Blues – Kaz