Is there a simple way to comment out a block of code in a shell script?
Google has some suggestions but they all seem awkward and ugly.
Is there a simple way to comment out a block of code in a shell script?
Google has some suggestions but they all seem awkward and ugly.
In bash:
#!/bin/bash
echo before comment
: <<'END'
bla bla
blurfl
END
echo after comment
The '' around the END delimiter is important, otherwise things inside the block like for example $(command) will be parsed and executed.
Find a good text editor. Newlines are usually the most effective comment-end tags, given an effective text editor.
There is no block comment on shell script.
Using vi ( yes vi ) you can easily comment from line n to m
<ESC>
:10,100s/^/#/
( that reads, from line 10 to 100 substitute line start (^) with a # sign. )
and un comment with
<ESC>
:10,100s/^#//
( that reads, from line 10 to 100 substitute line start (^) followed by # with noting //. )
vi is almost universal on anywhere where there is /bin/sh
:)
In Vim:
shift-V
(enter visual mode), up down highlight lines in block:s/^/#/
the command will look like this:
:'<,'>s/^/#
hit enter
e.g.
shift-V
jjj
:s/^/#
<enter>