Hi, I want to write a bash script that runs some root commands. The script is
#!/bin/bash
for i in `seq 1 235`;
do
root -b -q
.x masses_wrong_ratio_opt.C("/home/george/Desktop/wrong_weights/output/benchmark_ttH_1.dat.out") # runs the macro script that creates the root files
.q # exits root
mv ratio_wrng.root ratio_wrng_$i.root # changes the name of the root files
done
but it doesn’t seem to work. the output is
./wrong_ratio.sh: line 6: syntax error near unexpected token `('
./wrong_ratio.sh: line 6: ` .x masses_wrong_ratio_opt_C("/home/george/Desktop/wrong_weights/output/benchmark_ttH_'$i'.dat.out") # runs the macro script that creates the root files'
for i in {1..235}; do # in bash, you dont need to call seq
root -b -q masses_wrong_ratio_opt.C'("/home/george/Desktop/wrong_weights/output/benchmark_ttH_1.dat.out")'
done
The trick is to quote the parentheses and the double quotes as well. Easiest done using single quotes
It gets a bit messy if you want to use i instead of 1 in the filename: root -b -q masses_wrong_ratio_opt.C'("/home/george/Desktop/wrong_weights/output/benchmark_ttH_'${i}'.dat.out")'
Complely untested
Also, consider using root -b -q masses_wrong_ratio_opt.C+'("/home/geo ... to compile the code.
But how will the argument of the macro change if I don’t use i? I want each time to be "/home/george/Desktop/wrong_weights/output/benchmark_ttH_ΝUMBER.dat.out"
where NUMBER to span from 1 to 235… and then to exit root…
you can use with the escaping of " and ( : root.exe -l -b -q EmcalJetCDF.C\(\"local\",\"test\",\"data.txt\"\)
if you want to start more similar processes is better to have separate subdirs in which you will have the input,
a generic named symlink to input data and the output file
if the output file is root you can do hadd of the results at the end