Posterous

various ramblings

-- justin kelly

  • Blog
  • Home
  • Contact me
« Back to posts
  • Viewed
    times

Filed under

  • bash
  • linux
February 1, 2010

bash check if null

  • Edit
  • Delete
  • Tags
  • Autopost
expanding on the previous 'bash not null' post

to check if a string is null

 
 String='' # Zero-length ("null") string variable. 
 
if [ -z "$String" ] 
then 
 echo "\$String is null." 
else 
 echo "\$String is NOT null." 
fi # $String is null.