Last active
January 15, 2016 05:12
-
-
Save rlandas/9c4efe0ad3fb6d0c0a59 to your computer and use it in GitHub Desktop.
BASH: Checking if command line has arguments (@see http://linuxcommand.org/wss0130.php)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function testMe { | |
message=$1; | |
# check if there is an argument given | |
if [ "$1" != "" ]; then | |
echo -e "Test Me: $message\n"; | |
fi | |
# check if the variable contains something | |
if [ ! -z "$message" ]; then | |
echo -e "Hello there: $message\n"; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment