您好,登錄后才能下訂單哦!
用正則給ip對應的mac分割
[root@room1pc01 桌面]# cat ipmac.txt
192.168.4.5 121212452242
192.168.4.2 242426231251
192.168.4.3 242426231324
[root@room1pc01 桌面]#vim ipmac.txt
1 192.168.4.5 12:12:12:45:22:42
2 192.168.4.2 24:24:26:23:12:51
3 192.168.4.3 24:24:26:23:13:24
~
~
~
~
~
:%s /\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)$/\1:\2:\3:\4:\5:\6/g
[root@room1pc01 python]# grep -v "^$" kb |grep -v "^#"
# sed -i '/^$/d' 1.txt 刪除空白行
#sed -i '/^$/d' kb
#sed -i 's/^/AAA/' kb
#sed -i 's/$/BBB/' kb
#sed -i "s/^#an/an/" /etc/vsftpd/vsftpd.conf 刪除注釋
#sed -i "s/^an/#an/" /etc/vsftpd/vsftpd.conf 添加注釋
# sed '/id/s/[0-6]/5/' /etc/inittab
[root@vh03 00]# sed -i '/bash/s#/bin/bash#/sbin/nologin#' /etc/passwd
[root@vh03 00]# head -1 /etc/passwd
root:x:0:0:root:/root:/sbin/nologin
sed -i 'r /etc/passwd' 1.txt (在1.txt中每行下面都導入一個這樣文件內容 )
sed -i '1r /etc/passwd' 1.txt (在第一行導入內容)
# sed '2,3w y.txt' n.txt (把n.txx第二和第三行導出到y.txt中 之前內容被覆蓋了 且是真導入 不用-i)
[root@st5 ~]# cat y.txt
bbbbbbbbbb
ccccccccc
[root@st5 ~]# cat n.txt
aaaaaaaa
bbbbbbbbbb
ccccccccc
ddddddddd
(下面兩個命令相等)
#sed -n '/bash$/s/:.*//p' /etc/passwd
# awk -F: '/bash$/{print $1}' /etc/passwd
root
dc
45
[root@room1pc01 桌面]# awk '/bash$/{print $1}' /etc/passwd
root:x:0:0:root:/root:/bin/bash
dc:x:501:501::/home/dc:/bin/bash
45:x:502:502::/home/45:/bin/bash
[root@room1pc01 ~]# awk '{print $1}' 1.txt
[root@room1pc01 ~]# awk '/ma/' 1.txt (專門打條件,沒打指令是顯示該條件整行)
chi l ma ni
[root@room1pc01 ~]# awk '/ma/{print $1}' 1.txt (顯示該條件的行第一個
chi
[root@room1pc01 桌面]# awk '{print NR}' b.txt (顯示b.txt該文件有多少行號)
1
2
3
[root@room1pc01 桌面]# awk '/555/{print NR}' b.txt (顯示555在b.txt中第幾行)
[root@room1pc01 桌面]# awk '{print NF}' b.txt (顯示每行有多少列)
3
3
5
[root@room1pc01 桌面]# awk '{IP[$1]++} END{for(i in IP){print i,IP[i]}}' /var/log/httpd/access_log
192.168.4.254 2583
::1 80
[root@svr5 ~]# awk '{print $1}' /var/log/httpd/access_log |sort |uniq
80::1
2583 192.168.4.254
[root@svr5 ~]# who |awk '{IP[$1]++} END{for(i in IP) {print i,IP[i]}}'
root 2
[root@vh01 ~]# ifconfig eth0 |awk -F "[ :]" '/inet addr/{print $13}'
192.168.4.1
rpm包也可以用yum裝 不需要用rpm -ivh *.rpm (這樣可以解決依賴關系)
date -d @'1000'
去掉文件中的空行,并給有數據的行前面加AAA后面加BBB。
sed -i '/^$/d' kb
sed -i 's/^/AAA/' kb
sed -i 's/$/BBB/' kb
[root@room1pc01 python]# cat kb
dasdafdsf
fsadfas
f
#dfsadfas
#fasd
#f
#fasdfas
#df
#as
[root@room1pc01 python]# sed -i '/^$/d' kb
[root@room1pc01 python]# cat kb
dasdafdsf
fsadfas
f
#dfsadfas
#fasd
#f
#fasdfas
#df
#as
[root@room1pc01 python]# sed -i 's/^/AA/' kb
[root@room1pc01 python]# cat kb
AAdasdafdsf
AAfsadfas
AAf
AA#dfsadfas
AA#fasd
AA#f
AA#fasdfas
AA#df
AA#as
[root@room1pc01 python]# sed -i 's/$/BB/' kb
[root@room1pc01 python]# cat kb
AAdasdafdsfBB
AAfsadfasBB
AAfBB
AA#dfsadfasBB
AA#fasdBB
AA#fBB
AA#fasdfasBB
AA#dfBB
AA#asBB
客戶端使用vnc和服務器同步屏幕
[root@room1pc01 桌面]# yum provides */vncviewer
[root@room1pc01 桌面]# yum -y install tigervnc
[root@room1pc01 桌面]# vncviewer
輸入ip和端口就ok
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。