以下测试在 CentOS 7.1 中进行。
test.service在中创建以下文件/usr/lib/systemd/system/
[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}不替换为 word hello world,直到它echo ${a}变为
echo $a: 工作echo $${a}: 工作
这$$意味着 aa bash 中进程的 pid,但是为什么可以使用$$这个技巧ExecStart来获得这个词hello world呢?