Wednesday, January 8, 2014

tcsh/csh tips for the bash user

The official shell in FreeBSD is tcsh/csh, and in Debian/Ubuntu, it's dash or bash. The back-story is, these fall into two families of shells: Ones derived from the original bourne shell (sh) which include bash, ksh etc. and those derived from the C shell which include csh, tsch, etc. These use slightly different commands for setting environment variables etc.
  • You can check the type of shell you are using by the commands echo $shell or echo $0
    Note: $0 is actually the name of the running process. It will return the name of the shell or shell script according to the context. Read more on that here: http://www.tldp.org/LDP/abs/html/othertypesv.html#CHILDREF2
  • You can get a list of all the shells installed on your system by typing
  • cat /etc/shells 
  • ..and also change the default one to a different shell (if you have the permissions) using the command chsh.
  • If you are moving from bash to tcsh, you will find your .bashrc file (or even .bash_profile, .profile) doesn't work anymore. It's the ~/.cshrc file in tcsh instead. And for setting environment variables, rather than the old command.. PATH= $PATH:$HOME/bin; export PATH you will have to use something like.. 
  • setenv PATH ${PATH}:${HOME}/bin
     Note the missing '='.

More related reading:

1 comment:

  1. Thanks for the echo $0 trick.
    Had to work in a csh-only machine some time back. Got tired of the limitations soon and moved to a local bash installation.

    ReplyDelete