Shell syntax
Segmenting the mac corresponding to ip by regularization
[root@room1pc01 Desktop] # cat ipmac.txt
192.168.4.5 121212452242
192.168.4.2 242426231251
192.168.4.3 242426231324
[root@room1pc01 Desktop] # 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:\ 6Unigram
[root@room1pc01 python] # grep-v "^ $" kb | grep-v "^ #"
# sed-I'/ ^ $/ d'1.txt delete blank lines
# sed-I'/ ^ $/ d' kb
# sed-I's / ^ / AAA/' kb
# sed-I's Universe BBB kb
# sed-I "s / ^ # an/an/" / etc/vsftpd/vsftpd.conf delete comments
# sed-I "s / ^ an / # an/" / etc/vsftpd/vsftpd.conf add comments
# sed'/ id/s/ [0-6] / 5max'/ 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 (import the contents of such a file below each line in 1.txt)
Sed-I'1R / etc/passwd' 1.txt (import content on the first line)
# sed'2 3w y.txt 'n.txt (the content is overwritten and imported without-I before exporting the second and third lines of n.txx to y.txt)
[root@st5 ~] # cat y.txt
Bbbbbbbbbb
Ccccccccc
[root@st5 ~] # cat n.txt
Aaaaaaaa
Bbbbbbbbbb
Ccccccccc
Ddddddddd
(the following two commands are equal)
# sed-n'/ bash$/s/:.*//p' / etc/passwd
# awk-F:'/ bash$/ {print $1}'/ etc/passwd
Root
Dc
forty-five
[root@room1pc01 Desktop] # 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 (the condition is specially made, and the entire line of the condition is displayed if the command is not given)
Chi l ma ni
[root@room1pc01 ~] # awk'/ ma/ {print $1} '1.txt (the first line showing the condition
Chi
[root@room1pc01 Desktop] # awk'{print NR} 'b.txt (shows how many line numbers the file has in b.txt)
one
two
three
[root@room1pc01 Desktop] # awk'/ 555 / {print NR} 'b.txt (shows the line of 555 in b.txt)
[root@room1pc01 Desktop] # awk'{print NF} 'b.txt (shows how many columns are in each row)
three
three
five
[root@room1pc01 Desktop] # awk'{IP [$1] + +} END {for (i in IP) {print iJournal 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 IP [I]}}'
Root 2
[root@vh01 ~] # ifconfig eth0 | awk-F "[:]" / inet addr/ {print $13}'
192.168.4.1
Rpm packages can also be packaged in yum without the need for rpm-ivh * .rpm (which solves dependencies)
Date-d @ '1000'
Remove the blank lines from the file and precede the lines with data with AAA followed by BBB.
Sed-I'/ ^ $/ d'kb
Sed-I's / ^ / AAA/' kb
Sed-I's Universe BBB Universe 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 Placement BBUnip'kb
[root@room1pc01 python] # cat kb
AAdasdafdsfBB
AAfsadfasBB
AAfBB
AA#dfsadfasBB
AA#fasdBB
AA#fBB
AA#fasdfasBB
AA#dfBB
AA#asBB
The client uses vnc to synchronize the screen with the server
[root@room1pc01 Desktop] # yum provides * / vncviewer
[root@room1pc01 Desktop] # yum-y install tigervnc
[root@room1pc01 Desktop] # vncviewer
Enter ip and port for ok