当前位置:网站首页>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
边栏推荐
- FTP service
- 2022 7/5 exam summary
- Dev gridcontrol 捕获按键事件
- 为啥谷歌的内部工具不适合你?
- 2W word detailed data Lake: concept, characteristics, architecture and cases
- A clear summary and configuration example of GPON has been highlighted
- The difference between FileInputStream and bufferedinputstream
- [xshell7 free download and installation]
- BGP选路原则
- mysql函数汇总之条件判断函数
猜你喜欢

Rack server expansion memory

Brief introduction to XML

Dev gridcontrol captures key events

Team members participate in 2022 China multimedia conference

Understand microservices bit by bit

关于期刊论文所涉及的一些概念汇编+期刊查询方法
分享高压超低噪声LDO测试结果(High Voltage Ultra-low Noise LDO)

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

Lnmp+wordpress to quickly build a personal website

Burp suite Chapter 4 advanced options for SSL and proxy
随机推荐
2022/7/7 exam summary
2022-07-13 group 5 Gu Xiangquan's learning notes day06
这是一张图片
The most complete network: detailed explanation of six constraints of MySQL
小蜜蜂吉他谱 高八度和低八度
全网最全:Mysql六种约束详解
A clear summary and configuration example of GPON has been highlighted
Software engineering -- dental clinic -- demand analysis
Table fix specific rows
General Dao interface design
One click deployment lamp and LNMP architecture
2022 / 7 / 16 exam summary
外卖小哥,才是这个社会最大的托底
JSP implicit object -- scope
Official Oracle document
Dev gridcontrol captures key events
Rack server expansion memory
Traversal mode of list, set, map, queue, deque, stack
The idea of stack simulating queue
咱就是来聊聊并发编程的三大核心问题。