我想运行一个调用命令的 bash 脚本,然后在脚本中设置一个变量,其中包含第一个命令的部分输出。就我而言,我想将变量设置URL
为https://loady-7jmiymbtlg-uc.a.run.app
.
my-script.sh
:
gcloud run deploy loady
# echo $URL <--- how to set this with the output from the above command
当我运行我的脚本(示例输出)时:
karl@Karls-MacBook-Pro ~ $ ./my-script.sh
Deploying container to Cloud Run service [loady] in project [loady] region [us-central1]
✓ Deploying new service... Done.
✓ Creating Revision...
✓ Routing traffic...
✓ Setting IAM Policy...
Done.
Service [loady] revision [loady-00001-nod] has been deployed and is serving 100 percent of traffic.
Service URL: https://loady-7jmiymbtlg-uc.a.run.app
如您所见,最后一行。