在.cshrc中设置PATH无效

时间:2013-05-13 11:06:32

标签: linux shell csh

在我的.cshrc中有两行:

setenv PATH /a/bin:$PATH
cd /a/

的结果
setenv

...
PATH=/a/bin:<original PATH>
...

的结果
ls -l /a/bin

-rwxr-x--x 1 evgeny evgeny 122 May 13 13:43 run_me

的结果
run_me 

run_me: Command not found.

如何解决?

1 个答案:

答案 0 :(得分:3)

Becasue tcshcsh使用不同的语法bash。你肯定比使用类似csh的shell吗?对于类似sh的shell(例如bash),您需要将命令添加到.profile

.cshrc

中尝试下一个
set path=(/a/bin $path)

和relog,或使用

source .cshrc #for re-read the cshrc
rehash #reread avialable commands in the path

编辑 - 测试结果

[me@orion]/home/me(135)> echo $0
-tcsh
[me@orion]/home/me(136)> mkdir a
[me@orion]/home/me(137)> cd a
[me@orion]/home/me/a(138)> echo 'echo "$0 here"' >run_me
[me@orion]/home/me/a(139)> chmod 755 run_me
[me@orion]/home/me/a(140)> cd
[me@orion]/home/me(141)> set path=($HOME/a $path)
[me@orion]/home/me(142)> rehash
[me@orion]/home/me(143)> run_me
/home/me/a/run_me here
相关问题