我有一个很长的bash脚本,其中我使用术语" patient_number = $ 1"来指示样本/患者#这样我就可以运行脚本:
sh myscript.sh 551
sh myscript.sh 1034
(即针对不同的患者)
脚本完美无瑕地运行,直到我完成最后一步,只是用awk排序一些东西:
awk '{ OFS = "\t" ; if ($5 + 6 >= 5) print > "Cflo"$patient_number"_5Xcovered_withcoverage.txt" }' /path/to/my/original/filefor"$patientnumber".txt
当我手动运行它时,命令本身就可以工作。但在这里,它开始创建无限数量的文件,取代" $ patient_number"带有一串数字和问号,如:
Cflo9?9945?9945?0?0?9_5Xcovered_withcoverage.txt
Cflo9?9948?9948?0?0?6_5Xcovered_withcoverage.txt
Cflo9?9951?9951?0?0?6_5Xcovered_withcoverage.txt
Cflo9?9952?9952?0?0?7_5Xcovered_withcoverage.txt
Cflo9?9956?9956?0?0?6_5Xcovered_withcoverage.txt
Cflo9?9957?9957?0?0?6_5Xcovered_withcoverage.txt
Cflo9?9961?9961?0?0?5_5Xcovered_withcoverage.txt
Cflo9?9968?9968?0?0?5_5Xcovered_withcoverage.txt
Cflo9?9972?9972?0?0?4_5Xcovered_withcoverage.txt
Cflo9?9976?9976?0?0?5_5Xcovered_withcoverage.txt
Cflo9?9977?9977?0?0?5_5Xcovered_withcoverage.txt
Cflo9?9979?9979?0?0?2_5Xcovered_withcoverage.txt
Cflo9?9980?9980?0?0?2_5Xcovered_withcoverage.txt
Cflo9?9983?9983?0?0?4_5Xcovered_withcoverage.txt
Cflo9?9984?9984?0?0?2_5Xcovered_withcoverage.txt
Cflo9?99?99?0?0?8_5Xcovered_withcoverage.txt
在我停止之前,我让它几乎运行到100万个文件。有谁知道可能导致这种情况的原因?
谢谢!
答案 0 :(得分:0)
实际上,我发现只需重新排列即可修复它。必须是双引号的问题:
来自:
awk '{ OFS = "\t" ; if ($5 + 6 >= 5) print > "Cflo"$patient_number"_5Xcovered_withcoverage.txt" }' /path/to/my/original/filefor"$patientnumber".txt
到此:
awk '{ OFS = "\t" ; if ($5 + 6 >= 5) print $0 }' /path/to/my/original/filefor"$patientnumber".txt > Cflo"$patient_number"_5Xcovered_withcoverage.txt