added example of grep

Mohammad Faisal
2021-03-10 17:51:33 +05:30
parent 91e801b485
commit e2c2552373

@@ -25,6 +25,12 @@ In bash/ksh, you can instead use `[[ .. ]]` which supports this behavior.
In sh, you can rewrite to use `grep`. In sh, you can rewrite to use `grep`.
```sh
if echo $var | grep -q '^[0-9]*$'; then
echo "$var is numeric"
fi
```
### Exceptions: ### Exceptions:
None. If you are not trying to match a glob, quote the argument (e.g. `[ $var == '*' ]` to match literal asterisk. None. If you are not trying to match a glob, quote the argument (e.g. `[ $var == '*' ]` to match literal asterisk.