【发布时间】:2016-01-10 21:15:56
【问题描述】:
以下测试在 CentOS 7.1 中进行。
在/usr/lib/systemd/system/中创建以下文件test.service
[Unit]
Description=Test Bash Brace Expansion
Wants=network.target
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "a='hello world'; echo ${a}"
[Install]
WantedBy=multi-user.target
并执行systemctl daemon-reload; systemctl restart test; systemctl status test -l
没有值的输出,因为${a} 不会替换为单词hello world,直到将echo ${a} 更改为
-
echo $a:工作 -
echo $${a}:工作
$$ 表示 bash 中进程的 pid,但为什么 $$ 可以在 ExecStart 中使用技巧来获得 hello world 这个词?
【问题讨论】:
标签: linux bash centos systemd brace-expansion