Hi, community! I want to transform BED to VCF files, but I will use echo to simplify the example. For that, I have two folders to access my BED files.
directory A: /home/caroca/strains/
folders: SRR800856 SRR800857 SRR800858
directory B: /home/caroca/strains/strain/results/
files for 1 folder: SRR800856_ngs_nonredundant.bed SRR800856_rel_nonredundant.bed
This is my code:
for i in SRR*; do
cd /home/caroca/strains/$i/results ;
for file in /home/caroca/strains/$i/results/$i_*_.nonredundant.bed ; do
echo $file ;
done ;
done
This is the stdout:
/home/caroca/strains/SRR800856/results/*_.nonredundant.bed
/home/caroca/strains/SRR800857/results/*_.nonredundant.bed
/home/caroca/strains/SRR800858/results/*_.nonredundant.bed
As you can see, the "*" should not stay there, instead it should be (the files of each folder):
/home/caroca/strains/SRR800856/results/SRR800856_ngs_nonredundant.bed
/home/caroca/strains/SRR800856/results/SRR800856_rel_nonredundant.bed
I tried multiple combinations and I don't know how to tackle it. Thank you in advance!
Hi,
Not sure if the error is related, but can you try this:
I think you need to add
{}
because_
might be a special character: ${i}.António
Thank you for your reply. Although this is what I got:
I think you need to spend some time understanding
bash
wildcards andparameter expansion
.I would also suggest using
find
with its-exec
flag for this instead.Thank you! I don't have a lot of experience with bash but I will pay a close look at that. Thanks