These days, I find the companies think highly of Linux operating abilities. And I do forget the features of Linux bash shell while I was writing the automatic hadoop setting tools. Consequently, I want to learn the bash shell script again and record the process somewhere.
This is my first record. I hope I will keep recording and make a progress. Bless me~
As it known to all, regex is a powerful tool for us to validate the strings. To validate the ip address, I wirte the shell script shown below.
The output:
Points:
1. if [[ $string =~ $regex ]]; then...
The operator '=~' is for the regex comparation while '==' is for the value camparation.
2. just as other languages, we need backslashes to match special charators.