【问题标题】:Environment variable is not setting globally环境变量未全局设置
【发布时间】:2017-12-31 09:15:27
【问题描述】:

我正在使用csh 终端。

.cshrc

setenv $files /home/ec2-user/files

.登录

if [ -f ~/.cshrc ]; then . ~/.cshrc fi

我正在尝试从 plink 回显 $files 值。 它显示错误 files: undefined variable

【问题讨论】:

  • 改用导出文件=/home/ec2-user/files
  • 不要使用csh。试试zsh。阅读csh considered harmful
  • @RamanSailopal,这是 csh,而不是 bash 或 posix。 export 不存在。

标签: linux csh


【解决方案1】:

设置变量时不要使用美元符号,仅在引用该变量时使用它。

setenv files /home/ec2-user/files

test 命令应该是大多数 csh/tcsh 实现中的内置命令,并且具有您将在man test 下看到的大部分相同功能。

test -f ~/.cshrc && source ~/.cshrc

请注意,通常情况下,csh/tcsh 会在运行 .login 之前自动运行您的 .cshrc.tcshrc 文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-07
    • 2011-12-12
    • 2013-11-10
    • 1970-01-01
    • 2018-06-29
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多