I have a long bash script in which I indicate a sample/patient # using the term "patient_number=$1" such that I can run the script as:
sh myscript.sh 551
sh myscript.sh 1034
(i.e. for different patients)
The script works flawlessly until I get to the final step, just sorting some things with awk:
awk '{ OFS = "\t" ; if ($5 + 6 >= 5) print > "Cflo"$patient_number"_5Xcovered_withcoverage.txt" }' /path/to/my/original/filefor"$patientnumber".txt
The command itself it works when I run it manually. But here, it begins to create infinite number of files, replacing "$patient_number" with a string of numbers and question marks like so:
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
I let it run almost to 1 million files before I stopped it. Does anyone know what may be causing this?
Thanks!