我正在尝试设置类路径,但收到错误。
文件代码:
# .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类路径时,它会打印BLANK。
当我通过putty访问服务器时,获取错误:
-bash:$' \ r':找不到命令 -bash:/home/test/.bash_profile:第16行:语法错误:意外的文件结尾
答案 0 :(得分:3)
语法错误可能与CRLF和CR problem有关,您可以通过在linux端编辑文件或使用丰富的编辑器(如notepad ++,您可以使用Linux换行符保存)来解决此问题,请参阅此{ {3}}
此外,您可能希望在.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.
答案 1 :(得分:1)
使用dos2unix .bash_profile
将Windows新行转换为UNIX新行。