How to put a line comment for a multi line command?

How to put a line comment for a multi line command?

This is how I do it. Essentially by using Bash’s backtick command substitution one can place these comments anywhere along a long command line even if it is split across lines. I have put the echo command in front of your example so that you can execute the example and see how it works:

Can you put a comment after a 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.

Are there any problems with Bash multiline script comments?

The main problem with this kludge is the arguments are still expanded, leading to a host of unintended consequences. The arguments are still affected by syntax errors, redirections are still performed so : > file will truncate file, and : $ (dangerous command) substitutions will still run.

How to add a comment to an input file?

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.

How does an unquoted parameter expansion work in Bash?

An unquoted parameter expansion undergoes word-splitting and pathname generation. In this case, neither process creates any additional words from an empty string, so the result is still an empty string. Such an empty string is simply discarded without affecting the command in which it appears.

How to write a multiline command using stack overflow?

Instead, you can be a dirty sneaky scripter from the wrong side of the tracks that don’t need no carats by swapping them out for a single pipe ( |) per continuation of a loop/expression: Thanks for contributing an answer to Stack Overflow!

How to ignore a multi line comment in SQL?

Multi-line SQL Comments start with /* and end with */ and anything between them would be ignored. In SQL if we want to ignore just a part of a statement, we can use the /* */ comment.

Can you run a multi line command from CMD?

But if you just want a multi-line conditional command to execute directly from CMD and not via a batch file, this should do work well. Let’s say you have something like this in a batch that you want to run directly in command prompt: