0

How to check whether the given value from the command line is a string or not in bash scripting?

eg: I will give input as stackoverflow from the command line and my bash script should check the given value is a string(i mean a sequence of characters) or a numeric value.

ravi
  • 1
  • 2
  • And what is your criterion for something, being a string? Bash is an untyped language, so it's not so clear what is a string, and what is not. – user unknown Mar 14 '18 at 00:58
  • Please, read [how to ask useful questions](https://stackoverflow.com/help/mcve). – LMC Mar 14 '18 at 01:26
  • 1
    All values in bash are sequences of characters (except when `declare -i` is in use, but it's poor form). Even `12` is a sequence of characters (first the character `1`, then the character `2`); and when you run `newvar=$(( 12 + 1 ))`, the value of `13` resulting from that is a string as well. – Charles Duffy Mar 14 '18 at 01:41

0 Answers0