简体   繁体   中英

.bashrc syntax error: unexpected end of file

I am getting an unexpected end of file error. I am not really sure how to fix it.

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions

export PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'

export LS_COLORS='di=35;1'


alias la='ls -lah'
alias cdu='cd /home/hzhang/primary'

#module load gnu-compilers/4.7.0
#module load mvapich3/gnu/1.7

.ls /opt/intel/Compiler/11.1/072/bin/ifortvars.sh intel64

#PATH=$PATH:/home/hzhang/primary/over2.2e/bin_dp:/home/hzhang/primary/foiltest
PATH=$PATH:/opt/overflow/intel/serial/bin_dp/:/home/hzhang/primary/chimera2.1/bin_dp/:/u/primary/hzhang/pegasus/bin_dp
export PATH

ulimit -s unlimited 

I had the same error due to missing "fi" line. Make sure to omit syntax errors. The original .bashrc is located in /etc/skel/. So just run the following command:

cp /etc/skel/.bashrc ~

I was facing a similar problem. Using the bash that comes with Windows 10, somehow the line endings had been changed to windows line endings (CRLF). Changing the file back to use unix line endings solved the issue.

Convert eh line endings to unix endings and see if that solves the issue. If editing in Vim, enter the command :set fileformat=unix and save the file. Several other editors have the ability to convert line endings, such as Notepad++ or Atom

Such syntax errors are really simple to find. At first glance the file looks okay, so I'd suggest you comment out every single line (with # ) and see if the error still manifests.

Then just do binary search, that is, comment in the first half of the file. If that works continue with the third quarter (otherwise with the first quarter). And so forth.

I had a similar problem, it turned out to be a missing "}" at the end of a function. I made a backup of the faulty one (in order to have an idea of what my setup was) and then copied the original fine (cp /etc/skel/.bashrc ~) and added the lines again.

I had the same issue because i made some changes in my .bashcr file and messed up the terminal. Follow command fixed my issue:

ecp /etc/skel/.bashrc ~

This .bashrc shall have been edited from windows. fromdos .bashrcé to correct this file in order to source it.

Just open the file from terminal by gedit .bashrc The document will open ,go to the bottom and see if fi is missing there,if it is not there add it.Just put "fi" at the left margin at the last and close all the commands with "fi". see here

I Swear not to use zsh again. it messed up my system trying to play around with it.

ecp /etc/skel/.bashrc ~

fixed my issue too

. . . if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi Fi In the first line of my terminal i got There is error at the end of the /.bashrc file but when i change Fi to fi it works fine like

. . . . if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM