mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
added example of grep
@@ -25,6 +25,12 @@ In bash/ksh, you can instead use `[[ .. ]]` which supports this behavior.
|
||||
|
||||
In sh, you can rewrite to use `grep`.
|
||||
|
||||
```sh
|
||||
if echo $var | grep -q '^[0-9]*$'; then
|
||||
echo "$var is numeric"
|
||||
fi
|
||||
```
|
||||
|
||||
### Exceptions:
|
||||
|
||||
None. If you are not trying to match a glob, quote the argument (e.g. `[ $var == '*' ]` to match literal asterisk.
|
Reference in New Issue
Block a user