当前位置:网站首页>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 ).
边栏推荐
- Uipath browser performs actions in the new tab
- 02 personal developed products and promotion - SMS platform
- Run xv6 system
- Integrated development management platform
- 【MySQL入门】第三话 · MySQL中常见的数据类型
- Selenium test of automatic answer runs directly in the browser, just like real users.
- node の SQLite
- Detailed explanation of data types of MySQL columns
- pip install pyodbc : ERROR: Command errored out with exit status 1
- Spark accumulator and broadcast variables and beginners of sparksql
猜你喜欢
sql语句优化,order by desc速度优化
FlutterWeb浏览器刷新后无法回退的解决方案
06个人研发的产品及推广-代码统计工具
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
Spark accumulator and broadcast variables and beginners of sparksql
PyTorch 提取中间层特征?
【MySQL入门】第一话 · 初入“数据库”大陆
Optimization of middle alignment of loading style of device player in easycvr electronic map
Integrated development management platform
Models used in data warehouse modeling and layered introduction
随机推荐
Models used in data warehouse modeling and layered introduction
Zen integration nails, bugs, needs, etc. are reminded by nails
Flink parsing (IV): recovery mechanism
遠程代碼執行滲透測試——B模塊測試
05个人研发的产品及推广-数据同步工具
TCP connection is more than communicating with TCP protocol
Example of batch update statement combining update and inner join in SQL Server
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
About selenium starting Chrome browser flash back
一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升
OpenCV中如何使用滚动条动态调整参数
How does wechat prevent withdrawal come true?
sql语句优化,order by desc速度优化
Remote code execution penetration test - B module test
Grafana 9 正式发布,更易用,更酷炫了!
C#WinForm中的dataGridView滚动条定位
【ASM】字节码操作 ClassWriter 类介绍与使用
VR全景婚礼,帮助新人记录浪漫且美好的场景
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
Unity particle special effects series - treasure chest of shining stars