当前位置:网站首页>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 ).

边栏推荐
- Spark calculation operator and some small details in liunx
- 视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
- Xin'an Second Edition: Chapter 12 network security audit technology principle and application learning notes
- 2022年大厂Android面试题汇总(一)(含答案)
- Debug and run the first xv6 program
- 虚拟机启动提示Probing EDD (edd=off to disable)错误
- Debug xv6
- TCP connection is more than communicating with TCP protocol
- Solr appears write Lock, solrexception: could not get leader props in the log
- Wechat applet obtains mobile number
猜你喜欢
![[getting started with MySQL] fourth, explore operators in MySQL with Kiko](/img/11/66b4908ed8f253d599942f35bde96a.png)
[getting started with MySQL] fourth, explore operators in MySQL with Kiko

Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system

【ASM】字节码操作 ClassWriter 类介绍与使用

酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅

Display picture of DataGridView cell in C WinForm

应用服务配置器(定时,数据库备份,文件备份,异地备份)

Spark accumulator and broadcast variables and beginners of sparksql

Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first

BearPi-HM_ Nano development environment

Concept and basic knowledge of network layering
随机推荐
The art of Engineering (1): try to package things that do not need to be exposed
The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
Unity tips - draw aiming Center
Precipitated database operation class - version C (SQL Server)
Error: Publish of Process project to Orchestrator failed. The operation has timed out.
10 advanced concepts that must be understood in learning SQL
Summary of Android interview questions of Dachang in 2022 (II) (including answers)
遠程代碼執行滲透測試——B模塊測試
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
Essai de pénétration du Code à distance - essai du module b
网络分层概念及基本知识
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
Reppoints: advanced order of deformable convolution
connection reset by peer
04 products and promotion developed by individuals - data push tool
Spark calculation operator and some small details in liunx
Solrcloud related commands
MySQL stored procedure
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
微信小程序获取手机号