Skip to content

Instantly share code, notes, and snippets.

@tamalw
Created August 4, 2008 20:11
Show Gist options
  • Save tamalw/3966 to your computer and use it in GitHub Desktop.
Save tamalw/3966 to your computer and use it in GitHub Desktop.
#!/bin.bash
regex='^[0-9]+$'
foo='1234'
bar='hi bean'
echo "foo = $foo"
if [[ "$foo" =~ $regex ]]; then
echo "$foo is an integer"
else
echo "$foo is a string"
fi
echo "bar = $bar"
if [[ "$bar" =~ $regex ]]; then
echo "$bar is an integer"
else
echo "$bar is a string"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment