LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why any command in .bashrc is being executed twice (https://www.linuxquestions.org/questions/linux-newbie-8/why-any-command-in-bashrc-is-being-executed-twice-4175451966/)

lxas 02-27-2013 04:22 PM

Why any command in .bashrc is being executed twice
 
This is my .bashrc file. Now as in the attached screenshot, it seems that the echo "Hello World" is being executed twice.
Could anybody please help me understand this? My emulator is LXTerminal.

# Add nano as default editor
export EDITOR=nano
alias ls='ls --color=auto'
#If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h: \W]\$ '

echo "Hello World"

chrism01 02-27-2013 06:24 PM

Can you check your .bash_profile; its normally called from there.

shivaa 02-27-2013 08:01 PM

Can you once share, what you see on terminal after you login i.e. enter in your session?

Also the same could be there in .profile file as well. Since shell executes .bashrc as well .profile or .login etc.

Code:

~$ grep 'Hello' .profile .login

lxas 02-28-2013 06:29 AM

Thank you very much for your reply. I see this when open LXTerminal:

Hello World
Hello World
[sakibccr@cdc: ~]$


And the grep output is this:

grep: .profile: No such file or directory
grep: .login: No such file or directory

I checked in the file manager, there is no .profile or .login file. My distro is Archbang with Openbox WM and SpaxeFM file manager.

Habitual 02-28-2013 07:15 AM

Quote:

Originally Posted by lxas (Post 4901147)
This is my .bashrc file. ...My emulator is LXTerminal.

# Add nano as default editor
export EDITOR=nano
alias ls='ls --color=auto'
#If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h: \W]\$ '

echo "Hello World"

First off, Much Respect for calling it by it's correct definition "emulator".
2nd: Is that the entire .bashrc file contents? It seems a bit "short".

lxas 02-28-2013 10:59 AM

Thank you very much @Habitual. I was using Ubuntu as my primary OS for quite some time, but could not gather much knowledge though.

Yes it is the entire .bashrc file.

Habitual 02-28-2013 11:18 AM

Quote:

Originally Posted by lxas (Post 4901732)
Thank you very much @Habitual. I was using Ubuntu as my primary OS for quite some time, but could not gather much knowledge though.

Yes it is the entire .bashrc file.

Well, we all recover from some things better than others.
You are in the right place to learn stuff. :)

Welcome to LQ.

I can't answer your question directly as to what may be the issue, I just ask the obvious more often than not.

Have you tried removing the 'echo "Hello World"' from .bashrc to see if the issue persists?
There is another option to create a new .bashrc from a skeleton file, but I am not clear on
those instructions.

Please be patient, someone much smarter than I will be along to help.

Have a Great Day!

shivaa 02-28-2013 07:43 PM

Quote:

Originally Posted by lxas (Post 4901553)
grep: .profile: No such file or directory
grep: .login: No such file or directory

In that case, if there's no .profile or .login, search .bashrc and all other executables inside home directory as:
Code:

~$ grep 'Hello' .bashrc
~$ grep 'Hello' ~/*



All times are GMT -5. The time now is 02:59 AM.