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

边栏推荐
- MySQL advanced (index, view, stored procedure, function, password modification)
- 06 products and promotion developed by individuals - code statistical tools
- 远程代码执行渗透测试——B模块测试
- 酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
- pip install pyodbc : ERROR: Command errored out with exit status 1
- 【MySQL入门】第一话 · 初入“数据库”大陆
- Selenium test of automatic answer runs directly in the browser, just like real users.
- Solrcloud related commands
- Openharmony developer documentation open source project
- 2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally
猜你喜欢

【MySQL入门】第一话 · 初入“数据库”大陆

2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally

FlutterWeb浏览器刷新后无法回退的解决方案

Automatic operation and maintenance sharp weapon ansible Foundation

Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter

06 products and promotion developed by individuals - code statistical tools

Spark accumulator and broadcast variables and beginners of sparksql

基本磁盘与动态磁盘 RAID磁盘冗余阵列区分

FlutterWeb瀏覽器刷新後無法回退的解决方案

Optimization of middle alignment of loading style of device player in easycvr electronic map
随机推荐
The most complete tcpdump and Wireshark packet capturing practice in the whole network
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
Solrcloud related commands
Binary search strategy
Unity粒子特效系列-闪星星的宝箱
Flink analysis (I): basic concept analysis
Solid principle
About selenium starting Chrome browser flash back
基于STM32+华为云IOT设计的智能路灯
How uipath determines that an object is null
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
Single responsibility principle
node の SQLite
Huawei certified cloud computing hica
[introduction to MySQL] third, common data types in MySQL
The solution that flutterweb browser cannot be rolled back after refreshing
PyTorch 提取中间层特征?
Interpretation of Flink source code (I): Interpretation of streamgraph source code