#练习题1
在/usr/local/目录下创建一个名为test的目录,并在test目录下创建一个名称为test.txt的普通文件。
mkdir /usr/local/test
touch /usr/local/test/test.txt
使用find命令查找到刚刚创建的文件,尝试三种不同的查找方式或者组合使用三种不同的查找选项。
find /usr/local/test -name test.txt
#练习题3
使用find命令将查找到的test.txt文件通过xargs、exec、ok任一后续动作复制到/tmp/目录下。
find /usr/local/test -name test.txt -exec cp {} /tmp ;
#练习题4
将以下文本内容使用vi编辑器写入刚刚创建的test.txt文件中: zhang shuxue:76 english:89 lixl shuxue:64 english:92 wujj shuxue:88 english:71 caix shuxue:69 english:81 wangk shuxue:54 english:63
vi test.txt /user/local/test
a
粘贴
:wq
#练习题5
使用sed命令将文本中的冒号替换为空格,并将替换内容写入到文件中。
sed -i 's/:/ /g' /user/local/test/test.txt
#练习题6
使用sort命令对test.txt文件内容进行排序,按照数学分数从高到低的顺序进行排列。
sort -r -n -k 3 -t " " /user/local/test/test.txt
#其他练习:
#练习题7
nginx日志实战处理,统计NGINX日志内容(将以下文本信息写入到一个新文件access.log中),按照从高到低的顺序查看访问次数最多的IP,并统计访问次数 127.0.0.1 - - [04/Dec/2020:14:38:10 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 127.0.0.1 - - [04/Dec/2020:14:38:11 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 127.0.0.1 - - [04/Dec/2020:14:38:12 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 127.0.0.1 - - [04/Dec/2020:14:38:13 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 127.0.0.1 - - [04/Dec/2020:14:38:14 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 127.0.0.1 - - [04/Dec/2020:14:38:15 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-" 192.168.100.1 - - [04/Dec/2020:14:38:49 -0500] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-" 192.168.100.1 - - [04/Dec/2020:14:38:49 -0500] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.100.102/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" "-" 192.168.100.1 - - [04/Dec/2020:14:38:50 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:51 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:51 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:52 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:51 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:51 -0500] "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" "-" 192.168.100.1 - - [04/Dec/2020:14:38:52 -0500] "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" "-"