shell script EOF Usage Summary

Use EOF formatted disk

#! /bin/bash 

fdisk /dev/ram3 << EOF
n
p
1
2048
94371839
w
EOF

Use EOF to the file input, append, overwrite the contents of

[root@slave-server opt]# cat << EOF >test.sh 
> 123123123
> 3452354345
> asdfasdfs
> EOF
[root@slave-server opt]# cat test.sh 
123123123
3452354345
asdfasdfs

追加内容
[root@slave-server opt]# cat << EOF >>test.sh 
> 7777
> 8888
> EOF
[root@slave-server opt]# cat test.sh 
123123123
3452354345
asdfasdfs
7777
8888

覆盖
[root@slave-server opt]# cat << EOF >test.sh
> 55555
> EOF
[root@slave-server opt]# cat test.sh 
55555

EOF can be customized

2)自定义EOF,比如自定义为wang
[root@slave-server opt]# cat << wang > haha.txt
> ggggggg
> 4444444
> 6666666
> wang
[root@slave-server opt]# cat haha.txt 
ggggggg
4444444
6666666

Command is executed in the remote node

You can only execute specific commands

 ssh user@$host <<EOF 
 for osd in /var/lib/ceph/osd/ceph-*; do 
 ceph-objectstore-tool --data-path \$osd --no-mon-config --op update-mon-db --mon-store-path $ms.remote 
 done 
 EOF
Published 56 original articles · won praise 6 · views 6839

Guess you like

Origin blog.csdn.net/qq_23929673/article/details/100032983