I'm a novice in bash scripting. I wrote a script that concatenates many files from different directories into large files
#!/bin/bash
for f in foo/$1/*; do
if [ -d "$f" ]; then
for d in $f/*; do
if [ -d "$d" ]; then
file=$( echo ${d##*/} )
mkdir -p bar/$1/"$file"/fastq/
cat $d/*/fastq_pass/* >> bar/$1/"$file"/fastq/$file.fastq.gz
fi
done
fi
done
I've noticed that some of merged files lost 1-2 GB in size, which is weird because other files are ok. When I tried to do
cat foo/* >> bar/largefile.fastq.gz
there was no loss. So it's definitely because of my script. Where's error?
.gz
file by concatenating several smaller files together.