Roger Bowler’s Unix Tips for z/OS systems programmers


Unix Tips

How to set the Title Bar in an Xterm window
Add the following lines to .bash_profile in your home directory:
if [ "${TERM}" = "xterm" ]; then
  PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME%%.*}:${LOGNAME}\007"'
How to test the exit status of a pipe
The bash shell uses the exit status of the last command in the pipeline as the exit status of the entire pipeline. The other statuses are available via the PIPESTATUS variable, which is an array variable containing the exit statuses of all of the commands in the pipeline. Example:
   command1 | command2
   if [ "${PIPESTATUS[@]}" != "0 0" ]
      echo "*** ERROR ***"

Thanks to Chet Ramey for this tip

Last updated 15 Mar 2009