I have a string variable which could have values like below.
my_string=" "
my_string=" "
my_string="name1"
my_string="name 2"
I have to identify if my_string has only spaces/whitespaces and exit the program when it has only whitespaces. If it has one or two spaces inbetween, it's a valid string.
How to check if the string has only whitespaces and exit the shell script based on that.
Thank you.
/bin/sh, thecasestatement is your friend. It's not as powerful as a real regex engine, but if you don't want to usegrep, it's what you have (and it's often powerful enough). I can't speak beyond that because I still don't understand your requirements in any detail.