Sunday, February 12, 2012
11:31 AM

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