I know how to write a multi-line command in a Bash script, but how can I add a comment for each line in a multiline command?
CommandName InputFiles \ # This is the comment for the 1st line
--option1 arg1 \ # This is the comment for the 2nd line
--option2 arg2 # This is the comment for the 3nd line
But unfortunately, the comment after continuation character \
will break the command.
I'm afraid that, in general, you can't do what you're asking for. The best you can do is a comment on the lines before the command, or one single comment at the end of the command line, or a comment after the command.
You can't manage to intersperse comments inside a command this way. The \
s express an intent to merge lines, so for all intents and purposes you're trying to intersperse comments in a single line, which doesn't work anyway because a \
has to be at the end of the line to have that effect.