当前位置:网站首页>awk作业
awk作业
2022-07-26 08:12:00 【三俩两】
1、获取根分区剩余大小
df -h | tail -1 | awk '{print $4}'
2、获取当前机器ip地址
ifconfig ens160 | head -2 | awk '{print $2}'| grep "^1"
3、统计出apache的access.log中访问量最多的5个IP
awk '{print $1}' | sort -n |unip -c | tail -5 /access.log
4、打印/etc/passwd中UID大于500的用户名和uid
awk -F : '$3>500{print $3}' /etc/passwd
5、/etc/passwd 中匹配包含root或net或ucp的任意行
awk -F : '/(root|net|ucp)/ {print $0}' /etc/passwd
6、处理以下文件内容,将域名取出并根据域名进行计数排序处理(百度搜狐面试题)
test.txt
http://www.baidu.com/index.html
http://www.baidu.com/1.html
http://post.baidu.com/index.html
http://mp3.baidu.com/index.html
http://www.baidu.com/3.html
http://post.baidu.com/2.html
awk -F / '{print $3}' test.txt | sort | uniq -c | sort -n
7、请打印出/etc/passwd 第一个域,并且在第一个域所有的内容前面加上“用户帐号:”
awk -F : '{print "用户账号:"$1}' /etc/passwd
8、请打印出/etc/passwd 第三个域和第四个域
awk -F : '{print $3 " " $4}' /etc/passwd
9、请打印第一域,并且打印头部信息为:这个是系统用户,打印尾部信息为:“================”
awk -F : 'BEGIN{print "这个是系统用户"}{print $1}END{print "================"}' /etc/passwd
10、请打印出第一域匹配daemon的信息.
awk -F : '$1=="daemon"' /etc/passwd
11、请将/etc/passwd 中的root替换成gongda,记住是临时替换输出屏幕看到效果即可.
awk -F: 'gsub(/root/,"gongda")' /etc/passwd
12、请匹配passwd最后一段域bash结尾的信息,有多少条
awk -F: '$NF~/bash$/{print NR}' /etc/passwd | wc -l
13、请同时匹配passwd文件中,带mail或bash的关键字的信息
awk -F: '/root|mail/' /etc/passwd
边栏推荐
- Logical volume management (LVM)
- Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
- Rack server expansion memory
- Enterprise private network construction and operation and maintenance
- 2022/7/6 exam summary
- OSPF总结
- Team members participate in 2022 China multimedia conference
- JSP action -- usebean action
- SPSS用KMeans、两阶段聚类、RFM模型在P2P网络金融研究借款人、出款人行为规律数据
- 2022-07-13 group 5 Gu Xiangquan's learning notes day06
猜你喜欢

数组的介绍--Array
Share high voltage ultra low noise LDO test results

《门锁》引爆独居安全热议 全新海报画面令人窒息

一点一点理解微服务

外卖小哥,才是这个社会最大的托底

一键部署LAMP和LNMP架构

Recurrence of strtus2 historical vulnerability

我,35岁了。

2022-07-14 group 5 Gu Xiangquan's learning notes day07

Now developers are beginning to do testing. Will there be no software testers in the future?
随机推荐
No valid host was found when setting up openstack to create an instance There are not enough hosts available. code:500
C# 获取选择文件信息
Burp suite Chapter 9 how to use burp repeater
Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
2022-07-09 group 5 Gu Xiangquan's learning notes day02
Exam summary on July 13, 2022
Use js to count the number of occurrences of each string in the string array, and format it into an object array.
C # get the information of the selected file
The difference between equals() and = =
ORACLE 官方文档
Template summary
2022/7/6 exam summary
2W word detailed data Lake: concept, characteristics, architecture and cases
Establishment and use of openstack cloud platform
Table fix specific rows
Why don't you tell me what long polling is?
Matlab drawing black spots on two / three-dimensional drawings
2022/7/9 exam summary
Copy pcap file with producer consumer model
C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系