if $4 =="P"{
n_P=n_P+1;
print $2 > t_dis.txt
}
else if($4 =="S"){
n_P=n_P+1;
print $2 > t_dis.txt
}
The judgment condition of if is not executed at all, probably because the format of the file is not completely consistent, resulting in the format of $4 and P having only some symbols. At this time, the incomplete matching method can be used to judge whether the variable and the string are the same.
if $4 ~"P"{
n_P=n_P+1;
print $2 > t_dis.txt
}
else if($4 ~"S"){
n_P=n_P+1;
print $2 > t_dis.txt
}