Helping Hands Helping Hands - 3 months ago 3x
Linux Question

Getting issue with .bash_profile in linux

I am trying set class path but getting error.

File Code :

# .bash_profile

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

# User specific environment and startup programs

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


export PATH

It print BLANK when I echo Java classpath.

When I access server via putty , Getting error :

-bash: $'\r': command not found
-bash: /home/test/.bash_profile: line 16: syntax error: unexpected end of file


The syntax error may related to the CRLF and 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

Beside, you may want to write those scripts in .bashrc

The bash man page on my linux box says:

          The bash executable
          The systemwide initialization file, executed for login shells
          The personal initialization file, executed for login shells
          The individual per-interactive-shell startup file
          The individual login shell cleanup file, executed when  a  login
          shell exits
          Individual readline initialization file
          System readline initialization file

according to this post, the on OS X is an exception.

Mac OS X — an exception
An exception to the terminal window guidelines is Mac OS X’s, 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.