You are not logged in.

#1 2014-11-13 12:52:51

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

[FIXED] bash: #: command not found

Hi all,

Getting this bash error every time I open a terminal. I've done a bit of reading on this error but I can't quite figure out how to fix it.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

Any suggestions?

Last edited by Gwynplaine (2014-11-13 15:03:37)

Offline

#2 2014-11-13 13:04:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [FIXED] bash: #: command not found

It's almost certainly something in your bashrc or bashprofile - post those files.

Off the top of my head, the only way to get that error is to have a quoted pound sign:

$ "#"
bash: #: command not found

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-11-13 13:04:46

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

Hi!

Could you check the contents of the following files in you home directory: .bashrc .bash_profile .profile or any other files that starts with "." (dot) ?

Offline

#4 2014-11-13 13:38:17

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

Contents of .bashrc:

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

export EDITOR="nano"
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

alsi

Contents of .bash_profile:

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

I don't have a .profile file.

Offline

#5 2014-11-13 13:43:13

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [FIXED] bash: #: command not found

Check the configs of alsi.

Offline

#6 2014-11-13 13:57:51

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

If you couldn't find anything you could check which are the files that the terminal is trying to open when it is starting with the following:
strace -o out.txt -vf -s 1024 -e open terminal
just change the name with the terminal which you are using...after that check the contents of the out.txt there must be some other files in which you have "#" sign.

Another thing that you can check before strace-ing you could try to comment tha last line of .bashrc --> alsi just to be sure if this is the problem or not.

Offline

#7 2014-11-13 13:58:04

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

It did actually start around the time I installed Alsi (sorry, I forgot to mention). I stopped using Archey because it started to display my ram as "-1623/2gb" or something along those lines.

I'm confused though because I actually removed alsi from .bashrc before posting and still had the same issue and same output from "echo $PATH".

I'm also not entirely sure what I should be looking for in the config files?

Last edited by Gwynplaine (2014-11-13 14:04:52)

Offline

#8 2014-11-13 14:03:34

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

Could you paste me the command which you type because i don't see .bashrc or any other files to be included?
Or just try to comment the line in .bashrc and check again

#alsi

Last edited by npetrov (2014-11-13 14:05:51)

Offline

#9 2014-11-13 14:05:15

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

I removed it from .bashrc and used "sudo pacman -Rns alsi" to remove it and the problem remains.

Also, the contents of out.txt:

1325  open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libvte.so.9", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libX11.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxfce4ui-1.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgtk-x11-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgdk-x11-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libatk-1.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgdk_pixbuf-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgio-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpango-1.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgobject-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxfce4util.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libglib-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpangocairo-1.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpangoft2-1.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libfreetype.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libcairo.so.2", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXext.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libncursesw.so.5", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libSM.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libICE.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libstartup-notification-1.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXfixes.so.3", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXrender.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXinerama.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXi.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXrandr.so.2", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXcursor.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXcomposite.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXdamage.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpng16.so.16", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libffi.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgthread-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libharfbuzz.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libexpat.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libpixman-1.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libEGL.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-shm.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-render.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXau.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXdmcp.so.6", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libuuid.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-util.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libX11-xcb.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgraphite2.so.3", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-dri2.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-xfixes.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-shape.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libgbm.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libwayland-client.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libwayland-server.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libglapi.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libdrm.so.2", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-glx.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-dri3.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-present.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-randr.so.0", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxcb-sync.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libxshmfence.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/libXxf86vm.so.1", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
1325  open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/xfce4-terminal.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en_GB.utf8/LC_MESSAGES/xfce4-terminal.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en_GB/LC_MESSAGES/xfce4-terminal.mo", O_RDONLY) = 3
1325  open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/lib/gconv/gconv-modules", O_RDONLY|O_CLOEXEC) = 3
1325  open("/usr/share/locale/en_GB.UTF-8/LC_MESSAGES/glib20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en_GB.utf8/LC_MESSAGES/glib20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en_GB/LC_MESSAGES/glib20.mo", O_RDONLY) = 3
1325  open("/usr/share/locale/en.UTF-8/LC_MESSAGES/glib20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en.utf8/LC_MESSAGES/glib20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1325  open("/usr/share/locale/en/LC_MESSAGES/glib20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
1326  +++ exited with 0 +++
1325  +++ exited with 0 +++

Offline

#10 2014-11-13 14:11:37

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

Ok, could you please delete out.txt and try again this :
strace -o out.txt -vf -s 8096 -e open gnome-terminal
...and paste the contents again?

EDIT:
Because the content of the file must be longer you could paste in into pastebin and give me a link to it

Last edited by npetrov (2014-11-13 14:15:17)

Offline

#11 2014-11-13 14:17:59

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

I've decided to use pastebin for the sake of formatting.

Here's the output of the new out.txt http://pastebin.com/6edzA1XG

Edit:

Looks like we had the same idea about pastebin.

Last edited by Gwynplaine (2014-11-13 14:24:54)

Offline

#12 2014-11-13 14:27:09

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [FIXED] bash: #: command not found

After removing the alsi line from .bashrc have you source the same file or just continued to use the same shell. The new configuration won't take effect until you source it (either by source .bashrc or by logging in again).

Offline

#13 2014-11-13 14:35:58

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

I entered "source .bashrc" into my terminal and received the error once again. I've also rebooted since then and there's no change.

Offline

#14 2014-11-13 14:37:49

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: [FIXED] bash: #: command not found

One thing that can do this is a UTF BOM. (for example in your .bashrc)
It will look like this: (in your case # is the first line)

$ cat bad
#! /bin/bash
echo bad
$ bad
/home/main/bin/bad: line 1: #!: command not found
head -n 1 bad | hexdump -C
00000000  ef bb bf 23 21 20 2f 62  69 6e 2f 62 61 73 68 0a  |...#! /bin/bash.|

In vim:
:set bomb
:set nobomb

Offline

#15 2014-11-13 14:48:46

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

Sorry, I'm pretty confused by those instructions and when I attempted to enter it into terminal:

$ cat bad
cat: bad: No such file or directory

Offline

#16 2014-11-13 14:50:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [FIXED] bash: #: command not found

Gwynplaine wrote:

I entered "source .bashrc" into my terminal and received the error once again. I've also rebooted since then and there's no change.

Well that's very useful for narrowing it down - it is definitely something in your bashrc then.  Can you move/rename your bashrc and try starting a new terminal?  If this avoids the problem, just delete that bashrc and start fresh - this would hardly be an inconvenience as there is nothing customized in your bashrc.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#17 2014-11-13 14:51:47

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

If you try to open a a new gnome terminal as root did you receive the same error?

There is a syntax error in one of the files which gnome-terminal is sourcing during startup,  but we have to find which are these file to be able to find the error.
Procyon's assumption is a great one, but we need to know which are the files.
From the wiki https://wiki.archlinux.org/index.php/bash you could check which are the usual files ...

Last edited by npetrov (2014-11-13 14:52:10)

Offline

#18 2014-11-13 14:53:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [FIXED] bash: #: command not found

npetrov, sourcing his bashrc is sufficient to replicate the error message - so the problem must be in the bashrc file (or something invoked or included from it).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#19 2014-11-13 14:56:50

npetrov
Member
From: Spain, Barcelona
Registered: 2014-11-13
Posts: 6

Re: [FIXED] bash: #: command not found

Sure, sorry, i've missed that reply smile

Offline

#20 2014-11-13 15:02:33

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [FIXED] bash: #: command not found

Ok, problem is in .bashrc, but I do not see any syntax errors what-so-ever.

Offline

#21 2014-11-13 15:02:57

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

Thank you, everyone. I really appreciate all the help you've given me. I feel almost guilty for the amount of help I've received for such a simple thing.

I renamed .bashrc as Trilby suggested and the error had gone. So, I copied .bashrc back from /etc/skel/ to my home folder and again received no errors. Re-activated Alsi and everything worked fine.

Thanks again everyone.

Offline

#22 2014-11-13 15:10:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [FIXED] bash: #: command not found

I suspect (as Procyon's suggestions were also getting at) that you had somehow got some non-printable characters in there.  I don't recall what it is exactly, but there are a few utf characters that are effectively invisible - not even showing up as space - if one of these was embedded before one of the # signs, it could have this result.  These characters may have gotten into the file by copying and pasting a line from a website.

EDIT: one of those is utf character 2063 "invisible separator".  You can see it's effects in the following two examples:

$ $(echo -e "\u2063#")
bash: ⁣#: command not found

$ echo -e "\u2063# some comment" > fakebashrc
$ cat fakebashrc 
# some comment
$ source fakebashrc 
bash: ⁣#: command not found

Last edited by Trilby (2014-11-13 15:13:34)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#23 2014-11-13 15:14:46

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: [FIXED] bash: #: command not found

Ahh, I see. Thank you for that information. I'll make a point of keeping an eye on that.

Edit:

Thank you for adding that example. That should be very helpful in case I run into something similar in the future.

Last edited by Gwynplaine (2014-11-13 15:16:28)

Offline

#24 2014-11-13 15:42:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [FIXED] bash: #: command not found

A hex editor/viewer (like xxd which comes with vim) is handy to check out suspicious files:

$ xxd fakebashrc 
0000000: e281 a323 2073 6f6d 6520 636f 6d6d 656e  ...# some commen
0000010: 740a                                     t.

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB