Having some trouble with command substitution in a shell script. I've used this script before on another system, so not sure what's going on here. Seems like no matter how I enclose the commands to set the variable, I'm getting an empty variable. I've tried many different ways to enclose them ($()
, backticks, quotes). If it helps, I'm trying to submit an array job.
#!/bin/bash
#BSUB -q shared
#BSUB -W 23:55
#BSUB -M 51200
#BSUB -J windowCovR1
#BSUB -R "span[hosts=1]"
mem=$LSB_JOBINDEX
sample=`head -n "$mem" bednames.txt | tail -1 | awk '{print $2}'`
eval ${sample}
echo ${sample}
$mem
is being set properly, it's something with the sample
line. The echo
command prints an empty line.