Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Empty-string/UNIX-Shell/empty-string.sh
Normal file
13
Task/Empty-string/UNIX-Shell/empty-string.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# assign an empty string to a variable
|
||||
s=""
|
||||
|
||||
# the "test" command can determine truth by examining the string itself
|
||||
if [ "$s" ]; then echo "not empty"; else echo "empty"; fi
|
||||
|
||||
# compare the string to the empty string
|
||||
if [ "$s" = "" ]; then echo "s is the empty string"; fi
|
||||
if [ "$s" != "" ]; then echo "s is not empty"; fi
|
||||
|
||||
# examine the length of the string
|
||||
if [ -z "$s" ]; then echo "the string has length zero: it is empty"; fi
|
||||
if [ -n "$s" ]; then echo "the string has length non-zero: it is not empty"; fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue