您好,登錄后才能下訂單哦!
寫一個腳本,實現判斷192.168.0.0/24網絡里,當前在線用戶的IP有哪些
命令:
nmap -sP 192.168.0.0/24
腳本1#!/bin/bash
for I in
seq 1 255
do
ping -c 2 -W 2 192.168.0.$I &>/dev/null
if [ $? -eq 0 ]
then
echo -e "192.168.0.$I is up."
else
echo -e "192.168.0.$I is down."
fi
done
單詞及字母去重排序案例
[root@localhost scripts]# sed 's#[,.]##g' <test.log|tr " " "\n"|sort|uniq -c |sort -rn|head -5
4 the
3 to
2 was
2 months
2 I
[root@localhost scripts]#[root@localhost scripts]# tr " ," "\n" <test.log|awk '{S[$1]++}END{for(k in S) print S[k],k}'|sort -rn|head -5
4 the
3 to
2 was
2 months
2 I
[root@localhost scripts]#[root@localhost scripts]# awk -F "[ ,.]+" '{for(i=1;i<NF;i++)S[$i]++}END{for(k in S) print S[k],k}' test.log |sort -rn|head -5
4 the
3 to
2 was
2 months
2 I
[root@localhost scripts]#[root@localhost scripts]# sed 's#[,. ]##g' test.log|grep -o "."|sort|uniq -c|sort -rn|head -5
33 t
20 o
19 e
18 n
17 i
[root@localhost scripts]#
按字母出現頻率降序排序
方法1:去空格特殊字符后,然后利用grep的-o將字符豎向排列后處理。
[root@localhost scripts]# sed 's#[,. ]##g' test.log|grep -o "."|sort|uniq -c|sort -rn|head -5
33 t
20 o
19 e
18 n
17 i
[root@localhost scripts]#[root@localhost scripts]# sed 's#[,. ]##g' test.log|grep -o "."|awk '{S[$1]++}END{for(k in S) print S[k],k}'|sort -rn|head -5
33 t
20 o
19 e
18 n
17 i
[root@localhost scripts]#[root@localhost scripts]# sed 's#[,. ]##g' test.log|awk -F "" '{for(i=1;i<NF;i++)S[$i]++}END{for(k in S) print S[k],k}'|sort -rn|head -5
33 t
20 o
18 n
18 e
17 i
[root@localhost scripts]#
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。