当前位置:网站首页>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
边栏推荐
- Common methods of string: construction method, other methods
- Excel file parsing
- Stack simulation queue
- C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系
- Introduction to arrays -- array
- Software engineering -- dental clinic -- demand analysis
- Use js to count the number of occurrences of each string in the string array, and format it into an object array.
- 基础乐理 节奏联系题,很重要
- 2022-024ARTS:最长有效括号
- Dev gridcontrol captures key events
猜你喜欢

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

Dev gridcontrol captures key events

数组的介绍--Array

Stack simulation queue

AQS implementation principle

Traversal mode of list, set, map, queue, deque, stack

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

CentOS install mysql5.7

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

小蜜蜂吉他谱 高八度和低八度
随机推荐
Burp Suite-第八章 如何使用Burp Intruder
2022/7/6 exam summary
Official Oracle document
Burp Suite-第一章 Burp Suite 安装和环境配置
2022/7/7 exam summary
Function default parameters, arrow functions, and remaining parameters in ES6 - explanation
Let's talk about the three core issues of concurrent programming.
Why is Google's internal tools not suitable for you?
Exam summary on July 15, 2022
利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。
全网最全:Mysql六种约束详解
Burp suite Chapter 8 how to use burp intruder
Read and write of zip file
Oracle 常用函数
小蜜蜂吉他谱 高八度和低八度
If the thread crashes, why doesn't it cause the JVM to crash? What about the main thread?
[xshell7 free download and installation]
The most complete network: detailed explanation of six constraints of MySQL
2022-024ARTS:最长有效括号
mysql函数汇总之日期和时间函数