为什么登录时主目录下的.profile不起作用


0

我是UNIX的新手。我使用的是mac OS X 10.8。我在主目录下创建了.profile。但是,它在登录时不起作用。我总是要使用命令强制它工作$ . ~/.profile。有谁可以帮我解释一下?

另一个问题,我尝试编写一个Cshell名称wld并使其可执行。但是,我不能仅仅通过输入来调用它$ wld。我要打字$./wld。如何让它正常工作?

Answers:


2

如果存在〜/ .bash_profile或〜/ .bash_login,则bash不读取〜/ .profile。还要记住,〜/ .profile由命令解释器为登录shell执行,而〜/ .bashrc是针对非登录shell执行的。你可以在这里阅读更多内容:http//stefaanlippens.net/bashrc_and_others

脚本通常放在〜/ .bashrc中,这些代码在〜/ .profile中:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

请注意,OS X默认情况下为新的终端窗口运行登录shell。
slhck 2013年

@Nykakin:谢谢,我试过使用〜/ .bash_profile。有用。我也想练习Cshell,因为我在第二个问题中写道,我怎样才能运行可执行文件wld只需输入$ wld而不是$ ./wld
HuongOrchid 2013年

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.