【发布时间】:2018-01-10 16:28:51
【问题描述】:
我想在这个 bash 函数中间脚本中启用 sudo。我认为问题在于sudo -s 打开了一个新的shell,并且所有后续行都没有打印,因为shell 已退出。
function example {
echo "one"
sudo -s
echo "two"
echo "three"
}
我怎样才能让two 和three 也打印为 sudo?没有在每个之前添加sudo?
【问题讨论】:
-
how to run two commands in sudo? 的可能副本另外,使用heredoc 的选项是at this link,它更漂亮一些。
标签: linux bash shell unix sudo