tamalw (owner)

Revisions

  • 83d41a firblitz Mon Aug 04 13:11:39 -0700 2008
gist: 3966 Download_button fork
public
Public Clone URL: git://gist.github.com/3966.git
Embed All Files: show embed
integer_detection.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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