Skip to content

Instantly share code, notes, and snippets.

@telatin
Created March 2, 2018 17:04
Show Gist options
  • Save telatin/55fc0523ecf6cde0a7ea48ce445640c3 to your computer and use it in GitHub Desktop.
Save telatin/55fc0523ecf6cde0a7ea48ce445640c3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
echo "In this directory you have ${SamFilesCount}"
for SamFile in *.sam
do
echo -n "Converting ${SamFile}... "
samtools view -bS ${SamFile} | samtools sort -o ${SamFile}.bam -
samtools index ${SamFile}.bam
echo "Done!"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment