【发布时间】:2017-07-06 01:21:27
【问题描述】:
我像这样在.bashrc 中创建了一个函数;
#!/bin/bash
function test() { ls; }
export -f test
并像这样在新终端中调用它;
$ test
结果是test: command not found
我在访问.bashrc 中的函数时做错了什么?
【问题讨论】:
-
在调用函数之前你有没有运行
source .bashrc? -
很有趣,因为
test存在于任何系统上。 -
你的
.bashrc文件是在哪里写的?而且,你真的在运行bash吗? -
@jm666 test 不是函数的真实名称。我在这里编的,我讨厌 foo 和 bar
-
@codeforester 是的,我试过了,没有任何改变
标签: bash function shell unix command