I am on a linux workstation in a network, with an "old" distrib. Furthermore, login shell is enforced to CSH. I already asked to Admins if it would be possible to switch to another one (I would like to have bash), but it was a no-go...

Therefore, I am running bash from the command line, as an interactive non-login shell (actually I am using gnome and gnome-terminal with a profile that runs /bin/bash -i as the command). A lot, if not all of my scripts use bash so I run them from it invoking bash with a script. It is messy but it works.

I have .cshrc with environment variables, aliases and options for csh defined in a .login and a .cshrc files in my $HOME. I also have a .bashrc/.bash_profile(that redirects to .bashrc if this an interactive shell)/.bash_aliases with some other variables and some that are the same. When I run the bash shell, I inherit from the environments variables defined in my .login file. I would like to ignore everything that is set up in this one when I run bash.

I would like to know if there is an option to run bash, ignoring every other environment variables previously defined from my CSH login session when I run my BASH shell.

Do you have any ideas?

Thank you

2 Answers 2


Instead of manually unsetting variables you don't want to inherit, run bash using the env command:

env -i bash

The -i flag causes bash to ignore its inherited environment.

  • That is exactly what I was looking for! Thanks! Aug 10, 2012 at 8:01

You want to run bash as non-interactive shell, inside CSH, with bash variables defined in .bash_profile right?

You could give a shoot:

./bash --login
source ./bash --login

but i can't test it.

  • Thanks for answering. It did not do what I'd like too: a setenv $PLOUC "PLOUZ" defined in .cshrc is still giving me a PLOUZ when I do a echo $PLOUC after /bin/bash --login Aug 8, 2012 at 13:56
  • so after ./bash --login execute this source .bash_profile
    – okobaka
    Aug 8, 2012 at 14:14
  • Same result unfortunately... Aug 8, 2012 at 14:33
  • Bash itself could inherit var from environment that was executed from, look for proper switch in man bash. If you just want to remove variables from the enviroment just unset VARNAME1 VARNAME2.
    – okobaka
    Aug 8, 2012 at 14:45
  • 1
    Print them all: env | awk -F= '/^\w/ {print $1}' | xargs, then remove those important one and unset.
    – okobaka
    Aug 8, 2012 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .