bash shell

To add to your path: PATH=$PATH:$HOME/jpeg2eps_source (no spaces allowed)
The bash startup file (equivalent to a .cshrc file) is: .bashrc or .bash_login
Autocompletion in bash: kmgate () { ssh kmgate01.icrr.u-tokyo.ac.jp ; }
aliasing: alias ls='ls -G'   (color-coded ls)
the bash equivalent of setenv: export EDITOR="emacs -nw"

if statements:
if [ `hostname` == 'ldas-pcdev2' ]
    then echo "pcdev2: sourcing sgwb/S5/matlab/matlab_script_32bit.sh"
    source sgwb/S5/matlab/matlab_script_32bit.sh
fi
bash script preamble: #!/bin/bash
bash loop:
for i in {1..5}
do
  echo "test $i"
done

Does a file exist? if [ -f $file ]

Add, mod, and multiply variables with double-parentheses: trial=$((($@-1)%100 + 1))
...or use math inside square brackets:
x=$@
job=$[x+137]
If-then statements:
if [ $@ -eq 0 ]
then
  echo "job 0: exitting gracefully."
  exit
fi


Back to Resources