LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-30-2020, 12:57 PM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,167

Rep: Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393

that is obviously not the original file, there are more than 94 lines here. It also sources other files. This is not enough to catch the original issue.
This file can be sourced without any issue - at least worked for me.
 
1 members found this post helpful.
Old 06-30-2020, 01:01 PM   #17
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,820

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Greymug View Post
"line 94: syntax error: unexpected end of file". I then $ "cat -n .bashrc" finding that line 94 is blank. How to identify the problem?
Chances are that you've forgotten a closing parenthesis, quotation mark, or apostrophe somewhere before the named line. If you have access to an editor that highlights blocks of code contained in parentheses, brackets, braces, and the like, it's not too difficult to find out where your omission is. Even without such an editor, 93 line of code isn't a lot to carefully scan.

Good luck...
 
1 members found this post helpful.
Old 06-30-2020, 01:02 PM   #18
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,886
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Thereabouts line #4 add in the term "set -xv" and then run the file using ./bashrc and see if it ends with a complaint and also you should see plenty more debug output, because that's what that term will enable. The latest portion thereof you can paste in a code section, if not all of the debug output.
 
1 members found this post helpful.
Old 06-30-2020, 01:14 PM   #19
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,167

Rep: Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393Reputation: 7393
I think this is not that file. For example this is the .bashrc of the user, but the incorrect file is /root/.bashrc.
 
2 members found this post helpful.
Old 06-30-2020, 01:23 PM   #20
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,886
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by pan64 View Post
I think this is not that file. For example this is the .bashrc of the user, but the incorrect file is /root/.bashrc.
Perhaps, but if they add either debug or an intentional syntax error, we'll find out pretty quickly.
 
1 members found this post helpful.
Old 06-30-2020, 01:27 PM   #21
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
Do you still get this error when you bash ~/.bashrc? If not then the error is not in this file. It may be in /etc/profile, in one of /etc/profile.d/*.sh, any other shell startup file, or any file sourced from them.

Also, try cat -A .bashrc to catch any unexpected (and invisible) control characters.
 
1 members found this post helpful.
Old 06-30-2020, 01:36 PM   #22
Greymug
Member
 
Registered: May 2020
Posts: 51

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
unexpected eof .bashrc

Quote:
Originally Posted by rtmistler View Post
i see no errors and a quick copy/paste of the chunk nearby line 94, and just preceding, causes no error.

The if-fi statement before appears good also.

Maybe you have punctuation in there that doesn't show evident in the pasting of the file here? Such as do you have any tab characters in the file?

Mind i didn't try to run the whole script, just the area near the aliases.
i'm checking all punctuation. I'll get back to you. Thanks.
 
Old 06-30-2020, 01:39 PM   #23
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,886
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by Greymug View Post
i'm checking all punctuation. I'll get back to you. Thanks.
My next reply where I suggested adding debug output controls would probably help you. Notwithstanding the concern raised by pan64 that you are inspecting the incorrect file.

As far as checking for the simple thing of TABS, just put it into an editor and search for TAB. Typically works like a charm for me.

Last edited by rtmistler; 06-30-2020 at 01:42 PM.
 
1 members found this post helpful.
Old 06-30-2020, 01:44 PM   #24
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
@rtmistler. Shell doesn't distinguish between tab and space, make does. I'd rather suspect a rogue CR (carriage return) or some such.
 
1 members found this post helpful.
Old 06-30-2020, 02:10 PM   #25
Greymug
Member
 
Registered: May 2020
Posts: 51

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
unexpected eof .bashrc

Quote:
Originally Posted by rtmistler View Post
My next reply where I suggested adding debug output controls would probably help you. Notwithstanding the concern raised by pan64 that you are inspecting the incorrect file.

As far as checking for the simple thing of TABS, just put it into an editor and search for TAB. Typically works like a charm for me.
I found 5 "Tabs" lines 50-56 and replaced them with 3 spaces. Problem persists.
I'M NOW INSPECTING THE /ROOT/.BASHRC (Didn't know I had it!)
/root/.bashrc :is a total of 93 lines and few lines above has an "If" statement without any following "Fi". How do I alter that .bashrc file in the /root ???
 
Old 06-30-2020, 02:31 PM   #26
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
Code:
sudoedit /root/.bashrc
 
1 members found this post helpful.
Old 06-30-2020, 02:41 PM   #27
Greymug
Member
 
Registered: May 2020
Posts: 51

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
unexpected eof .bashrc

Quote:
Originally Posted by shruggy View Post
Code:
sudoedit /root/.bashrc
OK, I added the "fi". Like I said, I'm new. How do I resave it back to /root/.bashrc ??
 
Old 06-30-2020, 03:00 PM   #28
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
Is it nano? Then Ctrl+O. Ctrl+X to exit the editor.

Last edited by shruggy; 06-30-2020 at 03:03 PM.
 
1 members found this post helpful.
Old 06-30-2020, 03:49 PM   #29
Greymug
Member
 
Registered: May 2020
Posts: 51

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
unexpected eof .bashrc

Quote:
Originally Posted by shruggy View Post
Is it nano? Then Ctrl+O. Ctrl+X to exit the editor.
I added the "fi[enter]" (and replaced a few Tabs I found with spaces) and saved that file via "root@HPLap:/home/user# nano /root/.bashrc" plus your instrs ctrl-O and ctrl-X..........

...AND Identical error returned at line 95 (one line higher)!
----------------------I'm pasting entire /root/.bashrc-----------
@HPLap:~$ cat -n /root/.bashrc
1 # ~/.bashrc: executed by bash(1) for non-login shells.
2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
3 # for examples
4
5 # If not running interactively, don't do anything
6 [ -z "$PS1" ] && return
7
8 # don't put duplicate lines in the history. See bash(1) for more options
9 # ... or force ignoredups and ignorespace
10 HISTCONTROL=ignoredups:ignorespace
11
12 # append to the history file, don't overwrite it
13 shopt -s histappend
14
15 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
16 HISTSIZE=1000
17 HISTFILESIZE=2000
18
19 # check the window size after each command and, if necessary,
20 # update the values of LINES and COLUMNS.
21 shopt -s checkwinsize
22
23 # make less more friendly for non-text input files, see lesspipe(1)
24 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
25
26 # set variable identifying the chroot you work in (used in the prompt below)
27 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
28 debian_chroot=$(cat /etc/debian_chroot)
29
30 # set a fancy prompt (non-color, unless we know we "want" color)
31 case "$TERM" in
32 xterm-color) color_prompt=yes;;
33 esac
34
35 # uncomment for a colored prompt, if the terminal has the capability; turned
36 # off by default to not distract the user: the focus in a terminal window
37 # should be on the output of commands, not on the prompt
38 #force_color_prompt=yes
39
40 if [ -n "$force_color_prompt" ]; then
41 if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
42 # We have color support; assume it's compliant with Ecma-48
43 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
44 # a case would tend to support setf rather than setaf.)
45 color_prompt=yes
46 else
47 color_prompt=auto
48
49 if [ "$color_prompt" = yes ]; then
50 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
51 else
52 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
53 unset color_prompt force_color_prompt
54
55 # If this is an xterm set the title to user@host:dir
56 case "$TERM" in
57 xterm*|rxvt*)
58 PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
59 ;;
60 *)
61 ;;
62 esac
63
64 # enable color support of ls and also add handy aliases
65 if [ -x /usr/bin/dircolors ]; then
66 test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
67 alias ls='ls --color=auto'
68 #alias dir='dir --color=auto'
69 #alias vdir='vdir --color=auto'
70
71 alias grep='grep --color=auto'
72 alias fgrep='fgrep --color=auto'
73 alias egrep='egrep --color=auto'
74
75 # some more ls aliases
76 alias ll='ls -alF'
77 alias la='ls -A'
78 alias l='ls -CF'
79
80 # Alias definitions.
81 # You may want to put all your additions into a separate file like
82 # ~/.bash_aliases, instead of adding them here directly.
83 # See /usr/share/doc/bash-doc/examples in the bash-doc package.
84
85 if [ -f ~/.bash_aliases ]; then
86 . ~/.bash_aliases
87 fi
88
89 # enable programmable completion features (you don't need to enable
90 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
91 # sources /etc/bash.bashrc).
92 #if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
93 # . /etc/bash_completion
94
 
Old 06-30-2020, 03:54 PM   #30
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,688

Rep: Reputation: Disabled
There is a missing fi after the if in the line 65. Try this:
Code:
sudo sed -i '/alias egrep/a fi' /root/.bashrc

Ah wait, there is a missing fi after every if. Just
Code:
sudo cp /etc/skel/.bashrc /root/

Last edited by shruggy; 06-30-2020 at 04:06 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line execution error: unexpected EOF while looking for matching `"' bash: -c: line 25: syntax error: unexpected end of file maheshreddy690 Linux - Newbie 1 12-25-2018 01:13 PM
"Line 7 : syntax error near unexpected token ')' and Line 7: "option 1-?")" tiffney2018 Linux - Newbie 5 05-07-2016 03:35 PM
PHP Parse error: syntax error, unexpected end of file in Command line code on line 1 pizzipie Programming 8 12-11-2014 12:49 PM
Error in Bash: line 77: syntax error: unexpected end of file bribon Programming 8 07-13-2011 12:43 PM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration