当前位置:网站首页>Awk command exercise
Awk command exercise
2022-07-06 17:45:00 【JohnnyFang】
As one of the three swordsmen of the text ,awk The command has powerful functions in filtering data . Use awk On command , Fields separated by separators ( Column column, Domain field) Mark $1,$2...$n It's called a domain identifier ,$0 For all domains ( and shell Medium variable $ They have different meanings ), Each line becomes record, If omitted action, By default print $0 The operation of .
The requirements of this exercise are : Use awk Get... Separated by colons /ettc/passwd File first column .
perform cat /etc/passwd command , You can view all the information in the specified file , We need to screen out root、bin、daemon The information in this column ( Here's the picture ).
awk Common options include :
①-F “ Separator ” Indicates the field separator used for input , The default delimiter is several consecutive white space characters ;
②-v var=value Variable assignment
Just these two options can be used in this exercise , First look -F Options . Because it is separated by colon ,-F Followed by :( Add it here or not “” Fine ); The first column is filtered , The domain ID at the time of output is $1, The perform awk -F: '{print $1}' /etc/passwd Command to get the first column ( Here's the picture ).
Look again. -v Options , Use -v Option , We can use awk Built in variables in FS( Enter field separator , The default is blank , Function equivalent to -F), That is, the variable is assigned FS=":", perform awk -v FS=":" '{print $1}' /etc/passwd Can get /ettc/passwd File first column ( Here's the picture ).
边栏推荐
- How does wechat prevent withdrawal come true?
- Remote code execution penetration test - B module test
- Sqoop I have everything you want
- PySpark算子处理空间数据全解析(4): 先说说空间运算
- 一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升
- Flink parsing (VII): time window
- Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
- Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
- Summary of study notes for 2022 soft exam information security engineer preparation
- Vscode matches and replaces the brackets
猜你喜欢
Grafana 9 正式发布,更易用,更酷炫了!
About selenium starting Chrome browser flash back
Flink parsing (IV): recovery mechanism
PySpark算子处理空间数据全解析(4): 先说说空间运算
Basic configuration and use of spark
[ASM] introduction and use of bytecode operation classwriter class
The NTFS format converter (convert.exe) is missing from the current system
Models used in data warehouse modeling and layered introduction
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
随机推荐
【ASM】字节码操作 ClassWriter 类介绍与使用
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
[translation] principle analysis of X Window Manager (I)
Establishment of graphical monitoring grafana
[mmdetection] solves the installation problem
03 products and promotion developed by individuals - plan service configurator v3.0
Concept and basic knowledge of network layering
Based on infragistics Document. Excel export table class
应用服务配置器(定时,数据库备份,文件备份,异地备份)
Detailed explanation of data types of MySQL columns
Debug xv6
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
How uipath determines that an object is null
自动化运维利器ansible基础
Example of batch update statement combining update and inner join in SQL Server
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
【MySQL入门】第三话 · MySQL中常见的数据类型
EasyCVR授权到期页面无法登录,该如何解决?
C version selenium operation chrome full screen mode display (F11)