Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Empty string

  • ""
#!/bin/bash

read -p "Please type in your name: " name
if [ "$name" = "" ]
then
    echo "Name was missing"
    exit 1
fi
$ ./examples/script/empty_string.sh 
Please type in your name: Foo

$ ./examples/script/empty_string.sh 
Please type in your name: 
Name was missing