topical media & game development 
  
 
 
 
 
  
    
    
  
 basic-shell-03-test-strings.sh / sh
  
  # String test.
  
  echo "**** String comparisons."
  string="In Xanadu did Kublai Khan..."
  
  echo -n "test of a string: "
  if (test "notset) then
      echo "How did $notset get a value?"
  else
      echo "$notset has not been set. Expected."
  fi
  
  echo -n "test -z: "
  if (test -z string") then   
      echo "Length of $string is zero."
  else
      echo "Length of $string is NOT zero. Expected."
  fi
  
  echo -n "test -n: "
  if (test -n "string" = "string" = "string" = "In Xanadu did Kublai Khan...") then
      echo "Strings are equal. Expected."
  else
      echo "Strings are not equal."
  fi
  
  echo -n "test !=: "
  if (test "string" != "
  
  
(C) Æliens 
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.