博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bash shell ---- regex test
阅读量:5077 次
发布时间:2019-06-12

本文共 788 字,大约阅读时间需要 2 分钟。

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. 

b_large_Cf3a_275d000025cf1262.jpg

The output: 

b_large_NcIe_06440000084d1261.jpg

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.

转载于:https://www.cnblogs.com/Neoh/archive/2012/09/28/2706991.html

你可能感兴趣的文章
web服务器
查看>>
网卡流量检测.py
查看>>
poj1981 Circle and Points 单位圆覆盖问题
查看>>
POP的Stroke动画
查看>>
SQL语句在查询分析器中可以执行,代码中不能执行
查看>>
yii 1.x 添加 rules 验证url数组
查看>>
html+css 布局篇
查看>>
SQL优化
查看>>
用C语言操纵Mysql
查看>>
轻松学MVC4.0–6 MVC的执行流程
查看>>
redis集群如何清理前缀相同的key
查看>>
Python 集合(Set)、字典(Dictionary)
查看>>
获取元素
查看>>
proxy写监听方法,实现响应式
查看>>
第一阶段冲刺06
查看>>
十个免费的 Web 压力测试工具
查看>>
EOS生产区块:解析插件producer_plugin
查看>>
mysql重置密码
查看>>
jQuery轮 播的封装
查看>>
一天一道算法题--5.30---递归
查看>>