1.01 使用heredocument打印消息

打印常规消息 #

#!/bin/bash

cat << EOF
------------
This is line 1 of the essage.
This is line2 of the message.
This is line3 of the message.
This is line4 of the message
This is the last line of the message.
-------------
EOF

执行输出

------------
This is line 1 of the essage.
This is line2 of the message.
This is line3 of the message.
This is line4 of the message
This is the last line of the message.
-------------

打印抑制tab消息 #

#!/bin/bash

cat <<-EOF
------------
	This is line 1 of the essage.
	This is line2 of the message.
	This is line3 of the message.
	This is line4 of the message
 This is the last line of the message.
-------------
EOF

执行输出

------------
This is line 1 of the essage.
This is line2 of the message.
This is line3 of the message.
This is line4 of the message
 This is the last line of the message.
-------------

打印帮助信息 #

#!/bin/bash

DOC_REQUEST=80

if [ "$1" = "-h" -o "$1" = "--help" ]
then
  cat <<EOF
List the statistics of a specified directory in tabular format
---------------------------------------------------------------
The command line parameter gives the directory to be listed
EOF
exit $DOC_REQUEST
fi

打印的消息输入到文件 #

#!/bin/bash

cat > newfile << EOF
------------
This is line 1 of the essage.
This is line2 of the message.
This is line3 of the message.
This is line4 of the message
This is the last line of the message.
-------------
EOF

上一页➡️

下一页➡️

Calendar Aug 29, 2022
Edit Edit this page
本站总访问量:  次 您是本站第  位访问者