Can anyone suggest how to comment particular lines in the shell script other than #
?
Suppose I want to comment five lines. Instead of adding #
to each line, is there any other way to comment the five lines?
comment and uncomment a line with Shell Script Requirement is: 1. comment and uncomment the line with Shell Script: /opt/admin/fastpg/bin/fastpg.exe -c -=NET (using fastpg.exe as a search option) 2.
In Shell or Bash shell, we can comment on multiple lines using << and name of comment. we start a comment block with << and name anything to the block and wherever we want to stop the comment, we will simply type the name of the comment.
Single line comments start with // . Any text between // and the end of the line will be ignored by JavaScript (will not be executed).
When writing bash scripts, any text after a hash sign ( # ) indicates the start of a comment, and any text after # in the same line does not execute. When using a text editor or IDE, comments are colored differently from the rest of the code.
You can comment section of a script using a conditional.
For example, the following script:
DEBUG=false if ${DEBUG}; then echo 1 echo 2 echo 3 echo 4 echo 5 fi echo 6 echo 7
would output:
6 7
In order to uncomment the section of the code, you simply need to comment the variable:
#DEBUG=false
(Doing so would print the numbers 1 through 7.)
Yes (although it's a nasty hack). You can use a heredoc thus:
#!/bin/sh # do valuable stuff here touch /tmp/a # now comment out all the stuff below up to the EOF echo <<EOF ... ... ... EOF
What's this doing ? A heredoc
feeds all the following input up to the terminator (in this case, EOF) into the nominated command. So you can surround the code you wish to comment out with
echo <<EOF ... EOF
and it'll take all the code contained between the two EOFs and feed them to echo
(echo
doesn't read from stdin so it all gets thrown away).
Note that with the above you can put anything in the heredoc
. It doesn't have to be valid shell code (i.e. it doesn't have to parse properly).
This is very nasty, and I offer it only as a point of interest. You can't do the equivalent of C's /* ... */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With