1
The commandline command i want to run is an mkvmerge command:
mkvmerge arguments: [-o] [output_filename] [-a] [tracknumer] [-S] [source_filename]
So i have a variable command
and it takes on the values of either -a 1
, -a 1 -S
, or -S
depending on certain conditions being met, so i have this if statement in my bash script to run the command
if [[ ! -z $command ]]; then
mkvmerge -o "${file}"$command "$sourcefile"
fi
The reason i have $command
right next to ${file}
without a space is because $command
contains a single leading whitespace. The issue that i'm having is that when i run the script, it is assuming $command to be part of the filename and not as additional parameters that are meant to follow after the filename.
1Two spaces are also a valid separator, so you can try
"${file}" $command
... – xenoid – 2018-03-27T20:20:51.8731That indicates there isn't a leading space in the variable. Try printing it with
printf '"%s"\n "$command"
. – Gordon Davisson – 2018-03-27T23:50:09.600