当前位置:网站首页>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
边栏推荐
- Matlab-二/三维图上绘制黑点
- 这是一张图片
- Table fix specific rows
- Burp Suite-第二章 Burp Suite代理和浏览器设置
- Burp Suite - Chapter 2 burp suite proxy and browser settings
- If the thread crashes, why doesn't it cause the JVM to crash? What about the main thread?
- 正则表达式作业
- 利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。
- Burp Suite - Chapter 1 burp suite installation and environment configuration
- Exam summary on June 30, 2022
猜你喜欢

Use js to count the number of occurrences of each string in the string array, and format it into an object array.

Dev gridcontrol 捕获按键事件

SPSS uses kmeans, two-stage clustering and RFM model to study the behavior law data of borrowers and lenders in P2P network finance

Shardingjdbc pit record

2022-07-09 group 5 Gu Xiangquan's learning notes day02

Excel file parsing

宇宙第一 IDE 霸主,换人了。。。

Burp suite Chapter 9 how to use burp repeater

一键部署LAMP和LNMP架构

关于期刊论文所涉及的一些概念汇编+期刊查询方法
随机推荐
C# 获取选择文件信息
matplotlib学习笔记
NFS service and Samba service deployment
Burp suite Chapter 8 how to use burp intruder
2022/7/1
Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
One click deployment lamp and LNMP architecture
美女裸聊一时爽,裸聊结束火葬场!
Using ordered dictionary to copy pcap files
苹果强硬新规:用第三方支付也要抽成,开发者亏大了!
Summary of distributed related interview questions
2022/7/11 exam summary
Stm8 official library file download
2W word detailed data Lake: concept, characteristics, architecture and cases
Dev gridcontrol 捕获按键事件
给项目日志加上traceid
2022/7/9 exam summary
全网最全:Mysql六种约束详解
Excel file parsing
How WPS sets page headers page by page