linux 中的 .bash_profile 出现问题
Getting issue with .bash_profile in linux
我正在尝试设置 class 路径但出现错误。
文件代码:
# .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 classpath.
时打印空白
当我通过 putty 访问服务器时,出现错误:
-bash: $'\r': 找不到命令
-bash: /home/test/.bash_profile: 第 16 行:语法错误:文件意外结束
使用dos2unix .bash_profile
将Windows新行转换为UNIX新行。
语法错误可能与CRLF和CR有关problem, you may resolve this by edit the file in linux side or using a rich editor such as notepad++ which you can save using Linux newline, refer to this 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 是一个例外。
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.
我正在尝试设置 class 路径但出现错误。
文件代码:
# .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 classpath.
时打印空白当我通过 putty 访问服务器时,出现错误:
-bash: $'\r': 找不到命令 -bash: /home/test/.bash_profile: 第 16 行:语法错误:文件意外结束
使用dos2unix .bash_profile
将Windows新行转换为UNIX新行。
语法错误可能与CRLF和CR有关problem, you may resolve this by edit the file in linux side or using a rich editor such as notepad++ which you can save using Linux newline, refer to this 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 是一个例外。
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.