Trying to create a .bam file without the need for a .sam file I'm trying to use the code specified in this link to create a .bam file without the need for a .sam file.
Here is the code I'm using:
bwa mem -R &quot;@RG\tID:$SAMPLE\tPL:illumina\tSM:$SAMPLE&quot; \
    $REF_PATH/hg38.fasta \
    mapping/R1.fastq.gz \
    mapping/R2.fastq.gz | \
    samtools sort - | \
    tee mapping/$SAMPLE\.bam | \
    samtools index - mapping/$SAMPLE\.bam.bai \
    2&gt;&gt; log

and I get the following error:
[M::bwa_idx_load_from_disk] read 0 ALT contigs
`[E::main_mem] fail to open file ` '.

The ref path and file locations work when creating and converting a .sam to a .bam file.
Any ideas?
This is an error from bwa saying that it can't find your input files:
Here's a checklist:

Check that you have no whitespace after your \ newline breaks. I.e. \ is the very last character
Check that you have no whitespace in any path names
Quote your variables: $REF_PATH -&gt; &quot;$REF_PATH&quot;
Use set -x at the top of your bash script to debug.
In general, read this