别名是外壳特定的-
在这种情况下,很可能是bash特定的。要执行别名,您需要执行bash,但是别名仅针对交互式shell加载(更准确地说,
.bashrc仅针对交互式shell读取)。
bash -i 运行一个交互式外壳程序(以及源.bashrc)。 bash -c cmd 运行 cmd 。
将它们放在一起: bash -ic cmd 在交互式shell中运行 cmd ,其中 cmd
可以是您的中定义的bash函数/别名
.bashrc。
find -name *bar* | xargs bash -ic gi foo
应该做你想做的。
编辑:我看到您已经将问题标记为“
tcsh”,因此bash特定的解决方案不适用。使用tcsh时,您不需要
-i,因为除非您给出,否则它将显示为.tcshrc
-f。
尝试这个:
find -name *bar* | xargs tcsh -c gi foo
它适用于我的基本测试。



