day29sed学习笔记
sed是什么
sed是Stream Editor(字符流编辑器)的缩写,简称流编辑器。
sed常用于和正则表达式结合,实现对文件内容增删改查,最常用的功能是
- 过滤指定字符信息
- 取出指定的字符行
- 修改文件内容
sed语法格式
sed [选项] [sed内置命令字符] [输入文件]
说明:
1.注意 sed 软件及后面选项,sed 命令和输入文件,每个元素之间都至少有一个空格
2.为了避免混淆,文本称呼sed为sed软件.sed-commands(sed命令)是sed软件内置的一些命令选项,为了和前面的 options(选项)区分,故称为sed命令.
3.sed-commands 既可以是单个sed 命令,也可以是多个sed命令组合.
4.input-file(输入文件)是可选项,sed 还能够从标准输入或管道获取输入
sed软件的参数
options[选项]
解释说明
-n 取消默认的 sed 软件的输出,常与 sed 命令的 p 连用
-e 一行命令语句可以执行多条 sed 命令
-f 选项后面可以接 sed 脚本的文件名
-r 使用正则拓展表达式,默认情况 sed 只识别基本正则表达式
-i 直接修改文件内容,而不是输出终端,如果不使用-i 选项 sed 软件只是修改在 内存中的数据,并不影响磁盘上的文件
sed软件的命令
sed-commands[sed 命令]
解释说明
a 追加,在指定行后添加一行或多行文本
c 取代指定的行
d 删除指定的行
D 删除模式空间的部分内容,直到遇到换行符\n 结束操作,与多行模式相关
i 插入,在指定的行前添加一行或多行文本
h 把模式空间的内容复制到保持空间
H 把模式空间的内容追加到保持空间
g 把保持空间的内容复制到模式空间
G 把保持空间的内容追加到模式空间
x 交换模式空间和保持空间的内容
l 打印不可见的字符
n 清空模式空间,并读取下一行数据并追加到模式空间
N 不清空模式空间,并读取下一行数据并追加到模式空间
p 打印模式空间的内容,通常 p 会与选项-n 一起使用
P(大写) 打印模式空间的内容,直到遇到换行符\你结束操作
q 退出 sed
r 从指定文件读取数据
s 取代,s#old#new#g==>这里 g 是 s 命令的替代标志,注意和 g 命令区分
w 另存,把模式空间的内容保存到文件中
y 根据对应位置转换字符
:label 定义一个标签
t 如果前面的命令执行成功,那么就跳转到 t 指定的标签处,继续往下执行后 续命令,否则,仍然继续正常的执行流程
sed匹配文本范围
sed匹配文本范围
范围 | 解释 |
---|---|
空地址 | 全文处理 |
单地址 | 指定文件某一行 |
/pattern/ |
被模式匹配到的每一行 |
范围区间 | 10,20 十到二十行 ,10,+5第10行向下5行 ,/pattern1/,/pattern2/ |
步长 | 1~2,表示1、3、5、7、9行 ,2~2两个步长,表示2、4、6、8、10、偶数行 |
sed软件实践
准备测试数据
sed查找练习
测试数据
[root@nodel /opt16:22:31]#vim chaoge.log
[root@nodel /opt16:23:14]#cat chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt16:24:59]#
1.查找第2行
[root@nodel /opt16:24:59]#sed '2p' chaoge.log -n
I teach linux.
[root@nodel /opt16:26:23]#
2.查询第2行到第3行
[root@nodel /opt16:27:41]#sed '2,3p' chaoge.log -n
I teach linux.
I like play computer game.
[root@nodel /opt16:27:47]#cat chaoge.log -n
1 My name is yuchao. you can call me yuchao.
2 I teach linux.
3 I like play computer game.
4 My qq is 877348180.
5 My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
6 I love you.
7 I hate you,and thank u!
[root@nodel /opt16:27:56]#
3.按字包含game关键词的行
[root@nodel /opt16:27:56]#
[root@nodel /opt16:28:44]#sed '/game/p' chaoge.log -n
I like play computer game.
[root@nodel /opt16:29:03]#
4.查找以I开头的行
[root@nodel /opt16:30:32]#sed '/^I/p' chaoge.log -n
I teach linux.
I like play computer game.
I love you.
I hate you,and thank u!
[root@nodel /opt16:30:52]#
5.查找以.结尾的行
[root@nodel /opt16:32:20]#sed '/\.$/p' chaoge.log -n
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
I love you.
[root@nodel /opt16:32:26]#
6.查找linux到qq中间所有的行
[root@nodel /opt16:33:01]#sed '/linux/,/qq/p' chaoge.log -n
I teach linux.
I like play computer game.
My qq is 877348180.
[root@nodel /opt16:33:36]#cat -n chaoge.log
1 My name is yuchao. you can call me yuchao.
2 I teach linux.
3 I like play computer game.
4 My qq is 877348180.
5 My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
6 I love you.
7 I hate you,and thank u!
[root@nodel /opt16:33:56]#
7.查找第3行到http关键词的行
[root@nodel /opt16:34:52]#sed '/3,http/p' chaoge.log -n 直接写行号就不用加斜杠了
[root@nodel /opt16:35:05]#sed '3,/http/p' chaoge.log -n
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
[root@nodel /opt16:35:38]#
8.查找包含love或linux的行,需要用到扩展正则
[root@nodel /opt16:36:41]#sed -r '/love|linux/p' chaoge.log -n
I teach linux.
I love you.
[root@nodel /opt16:56:38]#
sed 增加练习
sed增加练习:
1.在第2行后面新添加一行 你是最棒的,奥力给!
[root@nodel /opt16:56:38]#sed '2a 你是最棒的,奥力给!' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
你是最棒的,奥力给!
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt16:58:37]#
2.在第2行前面新添加一行 你是最棒的,奥力给!
[root@nodel /opt16:58:37]#sed '2i 你是最棒的,奥力给!' chaoge.log
My name is yuchao. you can call me yuchao.
你是最棒的,奥力给!
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:05:19]#
3.在第2行后面新添加两行文本
你是最棒的,奥力给!
我帅过吴彦祖,富过李嘉诚!
[root@nodel /opt17:07:14]#sed '2a 你是最棒的,奥力给!\n我帅过吴彦祖,富过李嘉诚!' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
你是最棒的,奥力给!
我帅过吴彦祖,富过李嘉诚!
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:08:39]#
[root@nodel /opt17:08:39]#sed -e '2a 你是最棒的,奥力给!' -e '2a我帅过吴彦祖,富过李嘉诚!' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
你是最棒的,奥力给!
我帅过吴彦祖,富过李嘉诚!
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:09:19]#
4.在关键词http所在行前面添加一行 天下风云出我辈,一入江湖岁月催
[root@nodel /opt17:09:19]#sed '/http/i 天下风云出我辈,一入江湖岁月催' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
天下风云出我辈,一入江湖岁月催
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:13:36]#
sed替换练习
测试数据
[root@nodel /opt17:13:36]#vim chaoge.log
[root@nodel /opt17:14:58]#cat chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
练习题
1.将yuchao替换为 老于
[root@nodel /opt17:15:02]#sed 's#yuchao#老于#' chaoge.log
My name is 老于. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.老于it.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:18:33]#
[root@nodel /opt17:19:18]#sed 's#yuchao#老于#g' chaoge.log #全部替换
My name is 老于. you can call me 老于.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.老于it.cn , and another website is https://www.老于.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:21:00]#
2.将所有的'I'替换为'我'
[root@nodel /opt17:18:33]#sed 's#I#我#g' chaoge.log
My name is yuchao. you can call me yuchao.
我 teach linux.
我 like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
我 love you.
我 hate you,and thank u!
[root@nodel /opt17:19:18]#
3.只将第一次匹配上的a替换为A
[root@nodel /opt17:21:00]#sed 's#a#A#' chaoge.log
My nAme is yuchao. you can call me yuchao.
I teAch linux.
I like plAy computer game.
My qq is 877348180.
My website is http://www.yuchAoit.cn , and another website is https://www.yuchao.top/
I love you.
I hAte you,and thank u!
[root@nodel /opt17:21:44]#
4.只将第二次匹配上的a替换为A
[root@nodel /opt17:21:44]#sed 's#a#A#2' chaoge.log
My name is yuchAo. you can call me yuchao.
I teach linux.
I like play computer gAme.
My qq is 877348180.
My website is http://www.yuchaoit.cn , And another website is https://www.yuchao.top/
I love you.
I hate you,And thank u!
[root@nodel /opt17:22:16]#
5.忽略大小写替换 将my和替换为We
[root@nodel /opt17:22:16]#sed 's#my#we#Ig' chaoge.log
we name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
we qq is 877348180.
we website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:25:42]#
6.将第1行文本替换为 "当狂风在你耳边呼啸时,你只当它微风拂面;当暴雨在你眼前倾泻时,你只当它屋檐滴水."
[root@nodel /opt17:34:55]#sed '1 s#.*yuchao#当狂风在你耳边呼啸时,你只当它微风拂面;当暴雨在你眼前倾泻时,你只当它屋檐滴水#' chaoge.log
当狂风在你耳边呼啸时,你只当它微风拂面;当暴雨在你眼前倾泻时,你只当它屋檐滴水.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:35:49]#
sed 的c命令,把选定的行改为新的文本
[root@nodel /opt17:35:49]#sed '1c 当狂风在你耳边呼啸时,你只当它微风拂面;当暴雨在你眼前倾泻时,你只当它屋檐滴水.' chaoge.log
当狂风在你耳边呼啸时,你只当它微风拂面;当暴雨在你眼前倾泻时,你只当它屋檐滴水.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:39:15]#
sed删除练习
测试数据
[root@nodel /opt17:13:36]#vim chaoge.log
[root@nodel /opt17:14:58]#cat chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
练习题
sed删除练习:
1.删除第2行的内容
[root@nodel /opt17:39:15]#sed '2d' chaoge.log
My name is yuchao. you can call me yuchao.
I like play computer game.
My qq is 877348180.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:41:31]#
2.删除第2和第5行
[root@nodel /opt17:45:13]#cat chaoge.log -n
1 My name is yuchao. you can call me yuchao.
2 I teach linux.
3 I like play computer game.
4 My qq is 877348180.
5 My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
6 I love you.
7 I hate you,and thank u!
[root@nodel /opt17:45:16]#sed -e'2d' -e '5d' chaoge.log
My name is yuchao. you can call me yuchao.
I like play computer game.
My qq is 877348180.
I love you.
I hate you,and thank u!
[root@nodel /opt17:45:28]#
[root@nodel /opt17:45:28]#sed '2d;5d' chaoge.log
My name is yuchao. you can call me yuchao.
I like play computer game.
My qq is 877348180.
I love you.
I hate you,and thank u!
[root@nodel /opt17:46:04]#
3.删除第2行到第4行
[root@nodel /opt17:46:04]#sed '2,4d' chaoge.log
My name is yuchao. you can call me yuchao.
My website is http://www.yuchaoit.cn , and another website is https://www.yuchao.top/
I love you.
I hate you,and thank u!
[root@nodel /opt17:46:35]#
4.隔行删除 1~2,表示删除从第一行开始,隔一行删一行,步长为2(删除奇数行)
[root@nodel /opt17:46:35]#sed '1~2d' chaoge.log
I teach linux.
My qq is 877348180.
I love you.
[root@nodel /opt17:48:43]#
5.删除指定字符串game行之后的2行
[root@nodel /opt17:50:52]#sed '/game/ ,+2d' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I love you.
I hate you,and thank u!
[root@nodel /opt17:51:05]#
6.取反删除 只保留第1和第2行
root@nodel /opt18:09:21]#sed '1,2!d' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
[root@nodel /opt18:09:24]#
7.删除包含关键词yuchao的行
[root@nodel /opt19:02:28]#sed '/yuchao/d' chaoge.log
I teach linux.
I like play computer game.
My qq is 877348180.
I love you.
I hate you,and thank u!
[root@nodel /opt19:02:32]#
8.删除存在网址的行,如http[s]://www.xxx.com
[root@nodel /opt19:06:22]#sed '/https.*/d' chaoge.log
My name is yuchao. you can call me yuchao.
I teach linux.
I like play computer game.
My qq is 877348180.
I love you.
I hate you,and thank u!
[root@nodel /opt19:07:03]#
生产实践题
1.sed提取IP地址
测试数据
[root@nodel /opt19:07:03]#ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.250.100 netmask 255.255.255.0 broadcast 172.25.250.255
inet6 fe80::2a2:896b:255a:ef22 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:8c:d0:0d txqueuelen 1000 (Ethernet)
RX packets 4361 bytes 405692 (396.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2928 bytes 346998 (338.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
分组提取法
[root@nodel /opt19:22:34]#ifconfig ens33 | sed -nr '2 s#^.*inet\s(.*)\s+n.*#\1#'
[root@nodel /opt19:22:41]#ifconfig ens33 | sed -nr '2 s#^.*inet\s(.*)\s+n.*#\1#p'
172.25.250.100
[root@nodel /opt19:22:52]#
去掉ip前后的内容
[root@nodel /opt19:22:52]#ifconfig ens33 | sed -e '2s#^.*inet\s##' -e '2s#\snet.*##p' -n
172.25.250.100
[root@nodel /opt19:29:42]#
2.修改dns配置文件
[root@nodel /opt19:40:04]#sed 's#nameserver 233.5.5.5#nameserver 114.114.114.114#p' /etc/resolv.conf -n
nameserver 114.114.114.114
[root@nodel /opt19:40:12]#
[root@nodel /opt19:42:45]#sed '2c nameserver 233.5.5.5' /etc/resolv.conf -n
nameserver 233.5.5.5
[root@nodel /opt19:43:05]#
[root@nodel /opt19:47:24]#sed -r '2s#nameserver\s(.*)#nameserver 114.114.114.114#p' /etc/resolv.conf -n
nameserver 114.114.114.114
[root@nodel /opt19:47:35]#
3.修改nginx配置文件
运行用户改为www
默认的nginx运行用户
[root@nodel /opt19:47:35]#
[root@nodel /opt19:47:35]#grep -i '^user' /etc/nginx/nginx.conf
user nginx;
[root@nodel /opt19:49:53]#
修改为www
创建用户
[root@nodel /opt19:54:53]#sed -r '^user s#user nginx#user www#p' /etc/nginx/nginx.conf -n
sed: -e expression #1, char 1: unknown command: `^'
[root@nodel /opt19:54:59]#sed -r '/^user/ s#user nginx#user www#p' /etc/nginx/nginx.conf -n
user www;
[root@nodel /opt19:55:08]#
4.提取系统中所有用户名
[root@nodel /opt20:01:32]##(.*):x:.*:.*:.*:.*:.*
[root@nodel /opt20:03:31]#sed -r 's#(.*):x:.*:.*:.*:.*:.*#\1#pg' /etc/passwd -n
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
systemd-network
dbus
polkitd
sshd
postfix
hadoop
ztd
nginx
yuanlailinux
ycc01
yuchao01
yc01
yyc02
jerry2
david01
xman
chaoge001
sam
biber
jerry
bob001
jerry001
bob
chaoge01
jerry01
jack01
mysql
dockerroot
www
[root@nodel /opt20:04:03]#
5.提取/etc/passwd信息
uid
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@nodel /opt20:07:32]##.*:x:(.*):.*:.*:.*:.*
[root@nodel /opt20:08:32]#sed -r 's#.*:x:(.*):.*:.*:.*:.*#\1#pg' /etc/passwd -n
0
1
2
3
4
5
6
7
8
11
12
14
99
192
gid
[root@nodel /opt20:08:56]##.*:x:.*:(.*):.*:.*:.*
[root@nodel /opt20:09:40]#sed -r 's#.*:x:.*:(.*):.*:.*:.*#\1#pg' /etc/passwd -n
0
1
2
4
7
0
0
0
12
0
100
50
99
192
81
998
74
89
1000
1001
[root@nodel /opt20:10:01]##(.*):x:(.*):(.*):.*:.*:.*
[root@nodel /opt20:11:51]#sed -r 's#(.*):x:(.*):(.*):.*:.*:.*#\1:\2:\3#pg' /etc/passwd -n
root:0:0
bin:1:1
daemon:2:2
adm:3:4
lp:4:7
sync:5:0
shutdown:6:0
halt:7:0
mail:8:12
6.将/etc/passwd字段调换位置
第一列、最后一列、调换
[root@nodel /opt20:19:54]##(.*):x:(.*):(.*)::(.*):(.*)
[root@nodel /opt20:21:58]#sed -r 's#(.*):x:(.*):(.*)::(.*):(.*)#\5:x:\2:\3::\4:\1#pg' /etc/passwd -n
/sbin/nologin:x:89:89::/var/spool/postfix:postfix
/bin/bash:x:1000:1000::/home/hadoop:hadoop
/bin/bash:x:1001:1001::/home/ztd:ztd
/bin/bash:x:1501:1501::/home/yuanlailinux:yuanlailinux
/bin/bash:x:1700:1700::/home/cc01:ycc01
/bin/bash:x:1701:1701::/home/yuchao01:yuchao01
/bin/bash:x:1702:1702::/home/yc01:yc01
/sbin/nologin:x:1707:1707::/home/jerry2:jerry2
/bin/bash:x:1777:1777::/dacid01:david01
/bin/bash:x:1778:1778::/home/xman:xman
/bin/bash:x:1779:1779::/home/sam:sam
/bin/bash:x:1780:3000::/home/biber:biber
/sbin/nologin:x:1781:1781::/home/jerry:jerry
/bin/bash:x:1782:1782::/home/bob001:bob001
/bin/bash:x:1783:1783::/home/jerry001:jerry001
/bin/bash:x:1784:1784::/home/bob:bob
/bin/bash:x:2000:2000::/home/chaoge01:chaoge01
/bin/bash:x:1703:0::/home/jerry01:jerry01
/bin/bash:x:2001:2001::/home/jack01:jack01
/sbin/nologin:x:2002:2002::/home/www:www
[root@nodel /opt20:23:31]#
7. 批量修改文件名后缀
源数据
[root@nodel /opt20:28:09]#ll
total 0
-rw-r--r-- 1 root root 0 Apr 13 20:27 1.log
-rw-r--r-- 1 root root 0 Apr 13 20:27 2.log
-rw-r--r-- 1 root root 0 Apr 13 20:27 3.log
-rw-r--r-- 1 root root 0 Apr 13 20:27 4.log
-rw-r--r-- 1 root root 0 Apr 13 20:27 5.log
[root@nodel /opt20:28:11]#
[root@nodel /opt20:35:11]# ls | sed -rn 's#(.*).log#mv \1.log \1.txt#p' | bash
[root@nodel /opt20:35:45]#ls
1.txt 2.txt 3.txt 4.txt 5.txt
[root@nodel /opt20:35:48]#
8.修改文件内容,且备份文件
[root@nodel /opt20:43:21]#cp /etc/nginx/nginx.conf{,.ori}
[root@nodel /opt20:44:02]#ls /etc/nginx/nginx.conf*
/etc/nginx/nginx.conf /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf.ori
[root@nodel /opt20:44:06]#sed -r 's#listen\s+80#listen\s24444#p' /etc/nginx/nginx.conf -n
listens24444;
[root@nodel /opt20:45:20]#sed -r 's#listen\s+80#listen 24444#p' /etc/nginx/nginx.conf -n
listen 24444;
[root@nodel /opt20:45:31]#
9.提取nginx日志里的ip
[root@nodel /opt21:00:16]#tail -5 /var/log/nginx/access.log
172.25.250.1 - - [13/Apr/2022:20:59:19 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-"
172.25.250.1 - - [13/Apr/2022:20:59:20 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-"
172.25.250.1 - - [13/Apr/2022:20:59:20 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-"
172.25.250.1 - - [13/Apr/2022:20:59:21 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-"
172.25.250.1 - - [13/Apr/2022:20:59:21 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-"
[root@nodel /opt21:01:10]#
[root@nodel /opt21:01:10]#sed -r 's#(.*)\s-\s-.*#\1#g' /var/log/nginx/access.log | sort -n | uniq
172.25.250.1
[root@nodel /opt21:02:17]#
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!