From e2c255237339bb0479d090494ea8b316ab9430f5 Mon Sep 17 00:00:00 2001 From: Mohammad Faisal <1015900+faisal6621@users.noreply.github.com> Date: Wed, 10 Mar 2021 17:51:33 +0530 Subject: [PATCH] added example of grep --- SC2081.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SC2081.md b/SC2081.md index 10902d4..a5fe078 100644 --- a/SC2081.md +++ b/SC2081.md @@ -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. \ No newline at end of file