Skip to content

Instantly share code, notes, and snippets.

@rlandas
Last active January 15, 2016 05:12
Show Gist options
  • Save rlandas/9c4efe0ad3fb6d0c0a59 to your computer and use it in GitHub Desktop.
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)
#!/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