Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

class-7 积累应用

$
0
0

1、当天课程内容笔记

2、当天练习

3、预习

4、取本机ip地址

[root@6 ~]# ip addr|egrep -o '(\b([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b\.)(\b([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\.){2}\b([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4])\b'
10.1.252.177

5、取各分区利用率的数值

[root@6 ~]# df|grep 'sd'|tr -s ' ' ':'|cut -d: -f1,5|tr -d '%'
/dev/sda2:9
/dev/sda1:19
/dev/sda3:2

6、统计/etc/init.d/functions 文件中每个单词出现的次数,并按频率从高到低显示

[root@6 ~]# cat /etc/init.d/functions|tr -cs '[:alpha:]' '\n'|sort -n|uniq -c|sort -rn
83 if
77 then
75 pid
73 echo

7、/etc/rc.d/init.d/functions或/etc/rc.d/init.d/functions/" 取目录名

[root@6 ~]# echo '/etc/rc.d/init.d/functions'|egrep -o '^/.*/'
/etc/rc.d/init.d/
[root@6 ~]# echo '/etc/rc.d/init.d/functions/'|egrep -o '^/.*/'
/etc/rc.d/init.d/functions/

8、正则表达式表示身份证号

egrep ' (1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|8[1-2])[0-9]{4} [1-2]([8-9]|0)[0-9]{2}[0-1][0-9][0-3][0-9]{4}(x|[0-9])' [root@6 ~]# echo 512501197203035172|egrep '(1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|8[1-2])[0-9]{4}[1-2]([8-9]|0)[0-9]{2}[0-1][0-9][0-3][0-9]{4}(x|[0-9])'
512501197203035172

9、正则表达式表示手机号

echo 1853563316 |egrep '1(3[0-9]|5[0-3]|5[5-9]|7[078]|8[0-9])[0-9]{7}'
[root@6 ~]# echo 1853563316 |egrep '1(3[0-9]|5[0-3]|5[5-9]|7[078]|8[0-9])[0-9]{7}'
1853563316

10、正则表达式表示邮箱

[root@6 ~]# echo 123456789@hotmail.com | egrep '[[:digit:][:alpha:]_]+@.*.com'
123456789@hotmail.com

11、正则表达式表示QQ号

[root@6 ~]# echo 1234567890 |egrep '[1-9][0-9]{5,19}'
1234567890

Viewing all articles
Browse latest Browse all 11063

Trending Articles