用正则给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