Я не знаю, какие именно конкретные требования предъявляются к bash,
однако, если чтение входных данных из файла / пользователя является обязательным, то это должно работать
#!/bin/bash
cat parameterfile |awk 'BEGIN{
FS="\t";
}{
# If parameterfile has multiple lines, and you want to comment in them, prahaps
# if($0~"^[ \t]*#")next;
# Will allow lines starting with # (with any amount of space or tab in the front) to be reconized
# as comments instead of parameters :-)
#
# read the parameter file, whatever format it may be.
# Here we assume parameterfile is tab separated, so inside the BEGIN{} we specify FS as tab
# if it is a cvs , then A[0]=split($0,A,","); and then chr=A[1]; as such.
chr=$1;
start=$2;
end=$3;
name=$4;
# Lets start reading the file. We could read this from parameter file, if you want, or a -v var=arg on awk
file_to_read_from="bigfile.out";
while((getline line_of_data < file_to_read_from)>0){
# Since I do not have psychic powers to guess the format of the input of the file, here is some example
# If it is separated my more than one space
# B[0]=split(line_of_data,B,"[ ]");
# If it is separated by tabs
B[0]=split(line_of_data,B,"\t");
# Check if the line matches our specified whatever condition
if( B[1]==chr && B[3]>start && B[3]<end && B[11]<5E-2 ){
# Print to whatever destination
print > name".out";
}
}
# Done reading all lines from file_to_read_from
# Close opened file, so that we can handle millions of files
close(file_to_read_from);
# If parameterfile has multiple lines, then more is processed.
# If you only want the first line of parameter file to be read, then
# exit 0;
# should get you out of here
}'