#!/bin/sh -u # demonstrate the TEST command in an IF statement (string tests) # Reference: Chapter 11 # string comparison uses "=" not "-eq" (see middle of p.382) # -IAN! idallen@ncf.ca # Two different strings # if [ "dog" = "cat" ] ; then echo "dog/cat: two strings are equal" else echo "dog/cat: two strings are not equal" fi # Two same strings # if [ "dog" = 'dog' ] ; then echo "dog/dog: two strings are equal" else echo "dog/dog: two strings are not equal" fi # this next one produces an error message from TEST # use "=" not "-eq" for string comparisons (see middle of p.382) # if [ "dog" -eq "dog" ] ; then echo "dog/dog: two strings are equal" else echo "dog/dog: two strings are not equal" fi