Dear all, I create a code like this, which solve my problem to separate bam file to each segments, but still time I have one problem and I cannot finish it. I would like to create many outputs (files), which has name, same like variable $h. Than I want one think, if the for cycle for "h" finished, the code create a text fie with same name like $h.txt . I tried this, but it doesnt work:
#!/bin/bash
for h in {1..22..1}
do
for i in {0..249480000..60000}
do
u=$i let "u +=60000"
echo $i"-"$u | samtools view /home/filip/Desktop/Posledni\ NIFTY/019/odfiltrovany019.bam chr$h:$i-$u | awk '{ n=length($10);print gsub(/[GCCgcs]/,"",$10)/n;}'| awk '{s+=$1}END{print NR,s/NR}' > ${h%}.txt
done
done
OTUPUT will be 1.txt, 2.txt, 3.txt, ......., 22.txt. This file will contain information from loop cycle for variable i. Thank you.
maybe I am slow this morning but I do not fully understand the question plus the title is somewhat misleading. Could you put an example of the type of output you want ?
I do not know, how could I use > ${h%}.txt , because I want to receive on output txt files, which have name same like variable h. The code i OK, but I do not know how use the output syntax, after each loop (for variable h) I recieve one file with same name (1..22) and it will be filled by loop (for i).
This question is hardly bioinformatics related, apart from the samtools command. Also, I still don't understand what you're asking.