gpt4 book ai didi

linux - 在 Linux 中遇到 .bash_profile 问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:34:43 25 4
gpt4 key购买 nike

我正在尝试设置类路径但出现错误。

文件代码:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

export JAVA_HOME=/usr/java/jdk1.8.0_91/bin


PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

当我回显 Java 类路径时它打印空白。

当我通过 putty 访问服务器时,出现错误:

-bash: $'\r': 找不到命令-bash:/home/test/.bash_profile: 第 16 行:语法错误:文件意外结束

最佳答案

语法错误可能与 CRLF 和 CR 有关 problem ,您可以通过在 Linux 端编辑文件或使用功能丰富的编辑器(例如 Notepad++ )来解决此问题,您可以使用 Linux 换行符保存它,请参阅此 post

此外,您可能想在 .bashrc 中编写这些脚本

我的 linux 机器上的 bash 手册页说:

FILES
/bin/bash
The bash executable
/etc/profile
The systemwide initialization file, executed for login shells
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
~/.bash_logout
The individual login shell cleanup file, executed when a login
shell exits
~/.inputrc
Individual readline initialization file
/etc/inputrc
System readline initialization file

根据这个post , OS X 上的 terminal.app 是个异常(exception)。

Mac OS X — an exception
An exception to the terminal window guidelines is Mac OS X’s
Terminal.app, which runs a login shell by default for each new
terminal window, calling .bash_profile instead of .bashrc. Other
tGUI terminal emulators may do the same, but most tend not to.

关于linux - 在 Linux 中遇到 .bash_profile 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38422468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com