i am a beginner with bash and im trying to understand someone elses bash script. The script consists of several subsequent invokings of rscripts with certain parameters. All these if statements have roughly the same syntax, as follows:
if Rscript -options > log_file.txt 2>&1
script works, do smth.
else
script failed, leave the ship!
I simply cant get my head around why this if statement does what is does. I know that 2>&1 "combines" stderr and stdout. How does this syntax work exactly?
Thanks for the answers.