加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在新shell中运行bash命令,并在此命令执行后保留在新shell中

发布时间:2020-12-15 09:12:50 所属栏目:安全 来源:网络整理
导读:我有一个问题。我正在寻找很长时间的这个答案 – 我怎么能在新的bash shell中运行命令,并在此命令执行后保留在这个新shell。例如: bash -c "export PS1=' ' ls" 将使新的shell,导出PS1,列表目录和…将退出到我当前的shell。我想留在新的。 你可以通过滥
我有一个问题。我正在寻找很长时间的这个答案 – 我怎么能在新的bash shell中运行命令,并在此命令执行后保留在这个新shell。例如:
bash -c "export PS1='> ' && ls"

将使新的shell,导出PS1,列表目录和…将退出到我当前的shell。我想留在新的。

你可以通过滥用–rcfile选项来实现类似的东西:
bash --rcfile <(echo "export PS1='> ' && ls")

从bash manpage:

–rcfile file

Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读