I have a bash shell script that calls a C++ binary. I would like the output of the binary to be saved to a file, with a name based on run-time parameters that were used to call the binary.
#!/bin/bash
c_command="./code -v 1 -i file.txt -o out.txt -a 3 -w"
output=$($c_command)
echo output > ${c_command}_output.txt
Unfortunately, this is resulting in the following error:
./script.sh: line 4: ${c_command}_output.txt: ambiguous redirect
I was inspired by this stack exchange post, but clearly, something is not right.