bash - Shell 脚本 - 如何将脚本导出为字符串?
问题描述
我有一个大型 shell 脚本,我试图在 VM 启动时附加到 bashprofile:
我希望将此脚本附加到bashrc
文件中。我尝试了以下方法:
read -d '' load_script << EOF
// code here
EOF
但它会自动开始评估变量,我只想将此脚本推送到 bashrc 文件中。我怎样才能做到这一点?
脚本
writer_endpoint=$(aws neptune describe-db-clusters --db-cluster-identifier redacted | jq .DBClusters[0] | jq .Endpoint | tr -d '"')
reader_endpoint=$(aws neptune describe-db-clusters --db-cluster-identifier redacted | jq .DBClusters[0] | jq .ReaderEndpoint| tr -d '"')
writer_endpoint_status=$(awscurl https://$writer_endpoint:8182/status --service neptune-db | jq .status)
reader_endpoint_status=$(awscurl https://$reader_endpoint:8182/status --service neptune-db | jq .status)
cat << EOF
+==========+===============+
| Endpoint | Health Status |
+==========+===============+
| Reader | $writer_endpoint_status |
+----------+---------------+
| Writer | $reader_endpoint_status |
+----------+---------------+
********************************************************************************************************
Welcome to the bastion host, used to debug connectivity and queries against the Neptune graph DB.
********************************************************************************************************
[Reader Endpoint]:
$reader_endpoint
[Writer Endpoint]:
$writer_endpoint
[Example - Check status of reader replica]:
awscurl https://$writer_endpoint:8182/status --service neptune-db
*******************************************************************************************************
解决方案
推荐阅读
- c - 如何在 C 中使用浮点数和整数进行数学运算
- java - 为什么双除法返回一个非常错误的值?
- mysql - 选择每天每笔交易的总和和计数并显示它
- date - TYPO3 - 流体中的明天日期
- html - 创建响应式汉堡菜单
- google-sheets - 为当前单元格设置默认值 Google 电子表格
- scatter-plot - 想要在 Matplotlib 中的一个图中显示 76 个散点图,其中每个散点图的标题将基于字典中的键
- angular - 如何从另一个指令更改特定指令引用的属性值
- java - 使用 IntelliJ 构建项目时拒绝访问目标文件上的 java 可执行文件
- python - 使用 Pandas 提取 $ 符号后的字母