当前位置:网站首页>Awk operation
Awk operation
2022-07-26 08:13:00 【Two in three】
1、 Get the remaining size of the root partition
df -h | tail -1 | awk '{print $4}'
2、 Get the current machine ip Address
ifconfig ens160 | head -2 | awk '{print $2}'| grep "^1"
3、 According to the statistics apache Of access.log The most visited 5 individual IP
awk '{print $1}' | sort -n |unip -c | tail -5 /access.log
4、 Print /etc/passwd in UID Greater than 500 And uid
awk -F : '$3>500{print $3}' /etc/passwd
5、/etc/passwd The match contains root or net or ucp Any line of
awk -F : '/(root|net|ucp)/ {print $0}' /etc/passwd
6、 Process the following documents , Take out the domain name and count and sort it according to the domain name ( Baidu Sohu interview questions )
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、 Please print out /etc/passwd The first domain , And add “ User account number :”
awk -F : '{print " The user account :"$1}' /etc/passwd
8、 Please print out /etc/passwd The third domain and the fourth domain
awk -F : '{print $3 " " $4}' /etc/passwd
9、 Please print the first field , And the print header information is : This is the system user , Print the tail information as :“================”
awk -F : 'BEGIN{print " This is the system user "}{print $1}END{print "================"}' /etc/passwd
10、 Please print out the first field matching daemon Information about .
awk -F : '$1=="daemon"' /etc/passwd
11、 Please put /etc/passwd Medium root Replace with gongda, Remember to temporarily replace the output screen to see the effect .
awk -F: 'gsub(/root/,"gongda")' /etc/passwd
12、 Please match passwd The last field bash The message at the end , How many
awk -F: '$NF~/bash$/{print NR}' /etc/passwd | wc -l
13、 Please match at the same time passwd In file , belt mail or bash Keyword information
awk -F: '/root|mail/' /etc/passwd
边栏推荐
- JSP built-in object (implicit object) -- input / output object
- Burp Suite-第二章 Burp Suite代理和浏览器设置
- 我,35岁了。
- Share high voltage ultra low noise LDO test results
- Dev gridcontrol captures key events
- 随机分布学习笔记
- Lnmp+wordpress to quickly build a personal website
- If the thread crashes, why doesn't it cause the JVM to crash? What about the main thread?
- 2022-07-09 group 5 Gu Xiangquan's learning notes day02
- Use js to count the number of occurrences of each string in the string array, and format it into an object array.
猜你喜欢
随机推荐
C# 获取选择文件信息
Matlab drawing black spots on two / three-dimensional drawings
The bigger the project is, the bigger it is. This is how I split it
Stm8 official library file download
Common methods of string: construction method, other methods
AQS implementation principle
全网最全:Mysql六种约束详解
What are the differences between FileInputStream and bufferedinputstream?
2022-07-09 group 5 Gu Xiangquan's learning notes day02
Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
第三天作业
2022-07-08 group 5 Gu Xiangquan's learning notes day01
数组的介绍--Array
Ten thousand words long article | deeply understand the architecture principle of openfeign
Copy pcap file with producer consumer model
利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。
Team members participate in 2022 China multimedia conference
Exam summary on June 27, 2022
Web side 3D visualization engine hoops communicator reads 10g super large model test | digital twin Technology
美女裸聊一时爽,裸聊结束火葬场!









