check leading and trailing white space from a variable and fail the script
by dilip_d21 from LinuxQuestions.org on (#5SX9G)
Hi All ,
I was trying this for some time and can one one please help , consider variable called release has some value called 1.0.11 , i want to check that variable if it has any leading or trailing space and in case if it has any space then the script should fail , how can i achieve this ??
I tried the below code but this does not work
release=1.0.11
```if [ release=${release// } ]; then
echo "release version has trailing or leading whitespaces"
exit 1
else
echo "release version value is fine"
fi```
Any help much appreciated
I was trying this for some time and can one one please help , consider variable called release has some value called 1.0.11 , i want to check that variable if it has any leading or trailing space and in case if it has any space then the script should fail , how can i achieve this ??
I tried the below code but this does not work
release=1.0.11
```if [ release=${release// } ]; then
echo "release version has trailing or leading whitespaces"
exit 1
else
echo "release version value is fine"
fi```
Any help much appreciated