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/bash
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 ~
This .bashrc shall have been edited from windows. fromdos .bashrcé to correct this file in order to source it.
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 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
. . . 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
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.