I have written a zsh
script to automize an analysis in high energy physics and now I would like to use an element of the one of the defined array some string and another element of some another array in a command that is passed to one of the string. My code follows below:
bkgarr=(TopJets BosonJets DiBoson TTbar)
sigarr=(NM1 NM2 NM3 Scenario4 Scenario6)
puarr=(50PU 140PU)
lumarr=(30 300 3000)
echo Please type 1 for 50PU samples and 2 for 140PU samples
read PU
if [[ $PU -ne 1 && $PU -ne 2 ]] ; then
echo You have to enter 1 or 2
return 1
fi
echo Please type 1 for 300fb-1 and 2 for 3000fb-1
read lum
if [[ $lum -ne 1 && $lum -ne 2 ]] ; then
echo You have to enter 1 or 2
return 1
fi
if [ $PU = 1 ]; then
let "lum = $lum + 1"
#echo $lum
fi
root -l << EOF
.L readerSummerStd.C+
.q
EOF
ex NEWrunReader.py <<EOEX
:43s/Lumi.*/Lumi=$lumarr[lum]/
:x
EOEX
echo Press any key to proceed or Ctrl+C to abort!
read
for index in $bkgarr
do
screen -dmS $index"_"$lumarr[lum]
#screen -S $index -p 0 -X stuff "$(typeset -p bkgarr)"$'\r'
screen -S $index"_"$lumarr[lum] -p 0 -X stuff "./NEWrunReader.py SummerStd $puarr[PU]_$index >& $index"_"$lumarr[lum].txt &"$'\r'
done
for sigind in $sigarr
do
screen -dmS $sigin"_"$lumarr[lum]
#screen -S $sigind -p 0 -X stuff "$(typeset -p bkgarr)"$'\r'
screen -S $sigin"_"$lumarr[lum] -p 0 -X stuff "./NEWrunReader.py SummerStd $puarr[PU]_$sigind >& $sigind"_"$lumarr[lum].txt &"$'\r'
done
return 0
I thought the following code snippets would do, but they failed:
$index+"_"+$lumarr[lum]
$index"_"$lumarr[lum]
I would appreciate it if you could help me with this.
$lumarr[lum]
to${lumarr[$lum]}
and retry. – cuonglm Aug 31 '14 at 16:00zsh
.screen -S $sigin"_"$lumarr[lum]
would work inzsh
. – Stéphane Chazelas Aug 31 '14 at 18:14