Difference between revisions of "Shell Programming Tips"

From Aicip
Jump to: navigation, search
Line 2: Line 2:
  
  
* compare strings
+
* comparison. if it is string comparison, use "=="; if it is numeric comparison, use "-eq".
 +
 
 +
  MACHINE=`hostname`
 +
  if [ "$MACHINE" == "spider-3.ccs.ornl.gov" ]
 +
  then
 +
    export RUBYHOME=/chexport/tmp/fwang2/ruby191
 +
    PATH=$RUBYHOME/bin:$PATH
 +
    LD_LIBRARY_PATH=$RUBYHOME/lib/
 +
  fi
 +
 
 +
 
  
  
  
 
[[Category:AicipHelp]]
 
[[Category:AicipHelp]]

Revision as of 15:16, 4 February 2009

As much as I dislike shell programming, I need it sometimes. Here is a quick list of tasks I found most useful.


  • comparison. if it is string comparison, use "=="; if it is numeric comparison, use "-eq".
 MACHINE=`hostname`
 if [ "$MACHINE" == "spider-3.ccs.ornl.gov" ]
 then
   export RUBYHOME=/chexport/tmp/fwang2/ruby191
   PATH=$RUBYHOME/bin:$PATH
   LD_LIBRARY_PATH=$RUBYHOME/lib/
 fi