I am doing a RNA-Seq analysis and want to map my reads back to the assembly I got from Trinity. Below are my commands. I was hoping to get a single output file named low1.bam. Instead I got a lot of tmp files named like below:
The sorting of bam files is memory intensive, and samtools needs to create a lot of intermediary files (you can decrease the number of intermediary files, and increase sorting speed, by increasing the memory with samtools sort -m 8G). By defaut, samtools sort output to stdout, and you can output to a file with the -o low1.bam - which means you are using the -o option incorrectly. So samtools is creating all the necessary temporary files with a made-up name, usually the temporary file names it would be low1.0000.bam, low1.0001.bam, and so on.
With the latest version of samtools, you can sort directly, the intermediary samtools view is not needed. And without the -h option, the resulting bam file wouldn't contain headers.