Multiple command for bash shell script [duplicate]

2019-09-17 15:26发布

I want to assign a variable after executing the set of commands The first command is to get into the shell of the openshift pod. Then cat a file and assign that to a variable outside the openshift container.

I tried it like this

check=$(oc rsh pod << EOF
cat /var/lib/jenkins/.ssh/check.pub
EOF)

It gives me an error

bash: warning: here-document at line 41 delimited by end-of-file (wanted `EOF')

1条回答
霸刀☆藐视天下
2楼-- · 2019-09-17 15:50

I believe the second EOF needs to be on a line by itself:

check=$(oc rsh pod << EOF 
cat /var/lib/jenkins/.ssh/check.pub 
EOF
)
查看更多
登录 后发表回答