Last written comments in shell scripts, I did not expect so many people in need, there are also many problems. The right to be a supplement.
Single-line comments:
Single-line comments is relatively simple, direct line to the forefront together with the # symbol. DETAILED used as follows:
# this is comment test
echo "this is comment test"
operation result:
➜ comment git:(master) ✗ sh comment.sh
this is comment test
Multiline comments:
Multi-line comments There are many ways, here are a few common
As of 1 eof character
eof off not only used as the next input character command, it can also be used as a comment, common usage: Start Part Note: the input end section :: << eof: eof
Specific examples are as follows:
# echo is test
echo "test"
echo "test"
echo "test"
echo "test"
echo "test"
:<<eof
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
eof
operation result:
Comment git ➜: (master) ✗ bash comment.sh
test
test
test
test
test
2 exclamation point
! No. generally as an embedded part of the contents, the comment may be used, common usage: Start Part Note: Input << ::! End section:!
Specific examples are as follows:
# echo is test
echo "test"
echo "test"
echo "test"
echo "test"
echo "test"
:<<!
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
!
operation result:
Comment git ➜: (master) ✗ bash comment.sh
test
test
test
test
test
3 comma
Comma generally distinguish content, annotations can also be used, common usage: Start Part Note: input :: 'End Part:' (note that, to add a space between the comma and colon)
Specific examples are as follows:
# echo is test
echo "test"
echo "test"
echo "test"
echo "test"
echo "test"
: '
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
echo "comment"
'
operation result:
Comment git ➜: (master) ✗ bash comment.sh
test
test
test
test
test
Feel that this writing is relatively clear, I hope useful to you.