A special kind of redirect
Basic format:
command << token
text
token
- command is the name of the command that accepts standard input;
- token is used to indicate the end of the embedded text;
- text text content;
note:
- The token must appear in a separate line, and there is no space at the end of the text line;
- In the here document, quotation marks lose their special meaning;
<<-
Ignore Tab characters in the text;<< 'token'
You can ignore the command substitution, so that it does not perform any transfer;
Example 1: Ignore tabs
cat <<- HELP
该文件目的在于对镜像进行tar包转移。操作方法
save.sh [appname1]-[version1] [appname2]-[version2]
appname ----- 为镜像名字中的模块名称;
version ----- 为镜像名字中的模块版本号;
打包结果为一个以日期为命名的tar包;
默认镜像前缀为:”harbor.io:1180/szlt“,若要修改为其他的请进入文件修改变量”HARBOR_ADDRESS“的默认值
eg:
1. 对于镜像harbor.io:1180/aliyun/ucx:ec39fc1be7,使用方式为 save.sh ucx-ec39fc1be7
2. 对于镜像harbor.io:1180/aliyun/ucx:ec39fc1be7,harbor.io:1180/aliyun/apg:d4fdb86ff0;
使用方式为:save.sh ucx-ec39fc1be7 apg-d4fdb86ff0
HELP
Example 2: command can be any command that accepts standard input
#!/bin/sh
sqlplus "Sdadmin/admin" <<eof
@SD_P_CreateSeparatetable.prc;
eof
Example 3: Write text, and ignore the effect of quotation marks
[root@ccod4 ~]# echo $USER
root
[root@ccod4 ~]# cat << eof > a.sh
> "hello word,$USER"
> 'hello word,$USER'
>
> eof
[root@ccod4 ~]#
[root@ccod4 ~]#
[root@ccod4 ~]# cat a.sh
"hello word,root"
'hello word,root'
Example 4: Ignore command substitution
[root@ccod4 ~]# cat << 'eof' > a.sh
> "hello word,$USER"
> 'hello word,$USER'
> eof
[root@ccod4 ~]#
[root@ccod4 ~]# cat a.sh
"hello word,$USER"
'hello word,$USER'
Reference link:
http://c.biancheng.net/view/3109.html