第六次作業

1 、取本機ip地址

Centos6.8

ifconfig | head -2|tail -1|cut -d: -f2|cut -d" " -f1
ifconfig | head -2|tail -1|cut -d: -f2|cut -dB -f1

Centos7.2

ifconfig|head -2|tail -1|cut  -dt -f2|cut -d" " -f2

2 、查出分區空間使用率的最大百分比值

df|tr -s " "|cut -d" " -f5|tr -d '%'|tail -n +2

3 、查出用戶UID 最大值的用戶名、UID 及shell 類型

getent passwd|sort -n -t: -k3|cut -d: -f1,3,7|tail -1

4 、查出/tmp 的權限,以數字方式顯示

stat /tmp|head -n 4|tail -n +4|cut -d\( -f2|cut -d\/ -f1

5 、統計當前連接本機的每個遠程主機IP 的連接數,并按從大到小排序

netstat -nt|tr -s " "|cut -d" " -f5|cut -d: -f1|tail -n +3|sort|uniq -c|sort -n -r

6 、顯示/proc/meminfo 文件中以大小s 開頭的行;( 要求:使用兩種方式)

grep "^[Ss]" /proc/meminfo
egrep  "^(S|s)" /proc/meminfo
grep -i "^s" /proc/memsinfo

7、顯示/etc/passwd 文件中不以/bin/bash 結尾的行

grep -v /bin/bash$ /etc/passwd

8、顯示用戶rpc 默認的shell 程序

grep "^rpc\>" /etc/passwd|cut -d: -f7

9 、找出/etc/passwd 中的兩位或三位數

egrep -o "([[:digit:]]{2,3})" /etc/passwd

10、顯示/etc/grub2.cfg 文件中,至少以一個空白字符開頭的且后面存非空白字符的行

egrep "^[[:space:]]+[^[:space:]]" /etc/grub2.cfg

11、找出“netstat -tan” 命令 的結果 中以‘LISTEN’ 后跟任意多個空白字符結尾的行

netstat -tan|egrep "(LISTEN)[[:space:]]*$"

12 、添加用戶bash 、testbash 、basher 以及nologin( 其shell為 為/sbin/nologin), 而后找出/etc/passwd 文件中用戶名同shell名的行

egrep "^([[:alnum:]]*):.*\1$" /etc/passwd

13、統計/etc/init.d/functions 文件中每個單詞出現的次數,并按頻率從高到低顯示

cat /etc/init.d/functions |egrep -o "([[:alpha:]]*)" |sort|uniq -c|sort -n -r

14、/etc/rc.d/init.d/functions或/etc/rc.d/init.d/functions/"  取目錄名或基名

echo "/testdir/dir/dir1/"  | egrep -o ".*/\<"           #目錄名
echo "/testdir/dir/dir1/"  | egrep -o "([^/]+\/?)$"     #基名

15、正則表達式表示身份證號

egrep "\<((1[1-5])|(2[1-3])|(3[1-7])|(4[1-6])|(5[0-4])|(6[1-5])|(71|81|82))([0-9]){4}(19|20)([0-9]){2}((0[1-9])|(1[0-2]))(0[1-9]|(1[0-9])|(2[0-9])|(3[0-1]))([0-9]){3}([0-9]|X)\>" filename

16、正則表達式表示手機號

grep -E -o "(\+86)?1[38][0-9]{9}|14[57][0-9]{8}|15[0-35-9][0-9]{8}|17[0678][0-9]{8}" shoujihao

17、正則表達式表示郵箱

egrep "\<([[:alnum:]]+(-|_)*[[:alnum:]]*)\>@([[:alnum:]]+\.)+[[:alnum:]]+" mail 
grep -E -o '[a-zA-Z0-9]+[[:alnum:]\.\_-]*@[a-zA-Z0-9]+[[:alnum:]\.\_-]*' mail

18、正則表達式表示QQ號

grep -E -o '\b[1-9][0-9]{4,12}\b' QQ

原創文章,作者:NameLess,如若轉載,請注明出處:http://www.www58058.com/32396

(0)
NameLessNameLess
上一篇 2016-08-10 10:15
下一篇 2016-08-10 10:15

相關推薦

  • vim 作業

    4、如何設置tab縮進為4個字符?  vi/vim中,可以通過在~/.vimrc中添加set ts=4 執行source ~/.vimrc 重讀配置文件 5、復制/etc/rc.d/init.d/functions文件至/tmp目錄;替換/tmp/functions文件中的/etc/sysconfig/init為/var/log; 拓展模式下: &…

    學員作品 2016-08-15
  • 正則表達式

    grep:Global search REgular expression and Print out the line         文本搜索工具,根據用戶指定的”模式“對目標文本逐行進行匹配檢查;打印匹配到的行        模式:由正則表達式字符及文本字符所編寫的過濾條件…

    Linux干貨 2016-08-08
  • 馬哥團隊帶你領略阿里風景

    馬哥團隊帶你揭秘互聯網巨頭公司—阿里巴巴 繼馬哥團隊騰訊一行之后,4月中旬我們又來到了坐落于杭州的另一個互聯網巨頭公司。 波濤萬里長江水,帶你入杭州。 真情伴你走,春色為你留。 西湖煙水茫茫,百頃風潭,十里荷香。 風景甚好,怎能不去杭州的阿里巴巴轉轉呢? 帶著“淡妝”,走,跟著我們前行…… 馬哥更是笑道:“我們這次來是和馬云談合作的!讓我們培訓出來的更多同學…

    學員作品 2015-04-29
  • 磁盤及文件系統管理

    I/O Ports: I/O設備地址文件的處理方式:open,read,write,close設備類型:    塊設備:block,存取單位“塊”,磁盤    字符設備:char,存取單位“字符”,鍵盤設備文件:關聯至一個設備驅動程序,進而能夠跟與之對應硬件設備進行通信設備號碼: &nbs…

    學員作品 2016-08-30
  • Linux 用戶,組和用戶權限的使用

    echo -e "Hello,I am 'whoami',the system version is here,please helcheck ist  thanks! \n'lsb_release'"| mail -s 'help'root cmd1 |cmd 2 cma1 2&…

    2016-08-05
  • 文本處理工具sed及文本編輯器vim課程作業

    文本處理工具sed課程作業     1、刪除/etc/grub2.conf文件中所有以空白開頭的行行首的空白字符         sed -n 's@^[[:space:]]\+@@p' /etc/grub2.cfg &…

    學員作品 2016-08-10
欧美性久久久久