J. Magalhães Cruz

Some differences between BASH and TCSH

(or: Why I prefer BASH!)

Bash vs Tcsh: Table of Differences*
BASH TCSH Output generation BASH
output
TCSH
output
Comments
Shell variables x=3
# or: set x=3
# or: set x = 3
set x=3
# or: set x = 3
echo $x 3 3 with 'set', spaces are not important!
y="$x 4" set y="$x 4" echo $y 3 4 3 4
Environment variables
(children inherit them)
export z=5 setenv z 5 echo $z 5 5 Tcsh: why not 'setenv z = 5' ?!
export q="$z 6" setenv q "$z 6" echo $q 5 6 5 6
Shell & environment
variables
z=7 set z = 7 echo $z;
env|grep z
7
z=7
7
z=5
Tcsh: different shell and environment variables can have same name!
PATH & path
variables
export PATH=/a:/b set path=(/a /b) echo $path;
echo $PATH;
env|grep path
-
/a:/b
-
/a /b
/a:/b
-
Tcsh: why is there a 'path' shell variable?
Aliases alias ls="ls -l" alias ls "ls -l" ls (same as ls -l) (same as ls -l)
Command prompt PS1=abc- set prompt=abc- [ENTER] abc- abc-
Redirection prog > ofile 2> efile (prog > ofile) >& efile [ENTER] (stdout data in ofile; stderr data in efile) (stdout data in ofile; stderr data in efile) Bash: file descriptors can be used!
Login shell startup files
(order of shell parsing)
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
/etc/csh.cshrc
/etc/csh.login
~/.tcshrc
~/.cshrc
~/.login
Non-login shell startup files
(order of shell parsing)
~/.bashrc /etc/csh.cshrc
~/.tcshrc
~/.cshrc
Logout cleanup files ~/.bash_logout /etc/csh.logout
~/.logout
Scripting (Ba)sh: scripts are everywhere and are considered better!

* Feb.2015

References: