当前位置:网站首页>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
边栏推荐
- Libevent custom event (asynchronous)
- Burp Suite - Chapter 2 burp suite proxy and browser settings
- Abstract classes and interfaces
- 随机分布学习笔记
- Why don't you tell me what long polling is?
- 2022 / 7 / 16 exam summary
- Summary of distributed related interview questions
- es6中函数默认参数、箭头函数、剩余参数-讲解
- The difference between abstract classes and interfaces
- 小蜜蜂吉他谱 高八度和低八度
猜你喜欢

Why don't you tell me what long polling is?

一键部署LAMP和LNMP架构

NFS service and Samba service deployment

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

Burp suite Chapter 9 how to use burp repeater

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

Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合

Brief introduction to XML

A tutorial for mastering MySQL database audit characteristics, implementation scheme and audit plug-in deployment

基础乐理 节奏联系题,很重要
随机推荐
Common Oracle functions
Master slave database deployment
宇宙第一 IDE 霸主,换人了。。。
Spotty music data client_ ID account
关于期刊论文所涉及的一些概念汇编+期刊查询方法
Libevent custom event (asynchronous)
JSP implicit object servlet object
Burp suite Chapter 9 how to use burp repeater
The difference between equals() and = =
Read and write of zip file
要不你给我说说什么是长轮询吧?
An empirical study on urban unemployment in Guangxi (Macroeconomics)
2022-07-14 group 5 Gu Xiangquan's learning notes day07
C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系
Stack simulation queue
Exam summary on June 30, 2022
Idea settings set shortcut keys to convert English letters to case in strings
Rack server expansion memory
C # get the information of the selected file
Using producer consumer model and dpkt to process pcap files