如何使用shell脚本的.bashrc中定义的别名 [英] How to use aliases defined in .bashrc in shell script

查看:162
本文介绍了如何使用shell脚本的.bashrc中定义的别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在〜/ .bashrc中,我定义了一些别名。但我不能在其他shell脚本,在这里我只能用定义在那里的别名使用它们。即使我采购的.bashrc,它仍然没有奏效。我应该怎么办?

In ~/.bashrc, I defined some aliases. But I cannot use them in other shell scripts, where I can only use aliases defined right there. Even though I sourced bashrc, it still did not work. What should I do?

PS。我在bash。

PS. I'm in bash.

推荐答案

您需要做的禁用了javascript -s expand_aliases 中除了脚本采购〜/ .bashrc中

You need to do shopt -s expand_aliases in the script in addition to sourcing ~/.bashrc.

这篇关于如何使用shell脚本的.bashrc中定义的别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆