Created
May 20, 2011 02:30
-
-
Save dai0304/982239 to your computer and use it in GitHub Desktop.
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 | |
STR=ABC-0 | |
if [[ "$STR" =~ "-0$" ]]; then | |
echo A | |
else | |
echo B | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ ./test.sh
A
↑バージョン差異↓ が原因だろうか。bash v4の方で、結果をAにするにはどうしたらいいだろうか?
$ bash --version
GNU bash, version 4.1.7(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ ./test.sh
B