To comment a set of lines in a Shell script:
1) Using if false and fi
#!/bin/bash
a=2
if false
then
b=a
echo a
printf "-------\n"
fi
printf "%d %d\n", a, b
a=2
<<COMMENT
b=a
echo a
printf "-------\n"
COMMENT
printf "%d %d\n", a, b
3) Using Search and Replace option
To comment code between lines L1 and L2 we can use
:L1,L2s/^/#/
1) Using if false and fi
#!/bin/bash
a=2
if false
then
b=a
echo a
printf "-------\n"
fi
printf "%d %d\n", a, b
2) Using Comments
#!/bin/basha=2
<<COMMENT
b=a
echo a
printf "-------\n"
COMMENT
printf "%d %d\n", a, b
3) Using Search and Replace option
To comment code between lines L1 and L2 we can use
:L1,L2s/^/#/
No comments:
Post a Comment