Sunday, February 12, 2012

String Comparison Operators in Shell Script


Here are Some String Comparison operators used in Shell Script to compare two Strings.

OPERATOR DESCRIPTION
str1 = str2 True if str1 and str2 are identical
str1 != str2 True if str1 and str2 are not identical
-n str1 True if str1 is not null (size is greater than zero)
-z str1 True if str1 is null

Example
$ cat > strtest.sh
#!/bin/bash
a='sandeep'
b='sandeep'
c='vaibhav'
#null

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.