当前位置:网站首页>Use of shell cut command
Use of shell cut command
2022-04-23 17:06:00 【Magic Flute love】
cut
cut The job of “ cut ”, Specifically, it is used to cut data in the file .
cut Command to cut bytes from each line of a file 、 Characters and fields and put these bytes 、 Character and field output .cut After that, the original value was not changed
Basic usage
cut [ Option parameters ] filename
explain : The default separator is tab (\t)
Option parameter description
Option parameters | function |
---|---|
-f | Column number , Extract which column |
-d | Separator , Splits columns according to the specified separator |
Case practice
## Data preparation
[bd@localServer ~]$ touch cut.txt
[bd@localServer ~]$ vim cut.txt
fu xia
zhou men
wo wo
lai lai
le le
### cutting cut.txt First column
[bd@localServer ~]$ cut -d " " -f 1 cut.txt
fu
zhou
wo
lai
le
### cutting cut.txt second 、 The three column
[bd@localServer ~]$ cut -d " " -f 2,3 cut.txt
xia
men
wo
lai
le
### stay cut.txt Cut out in file zhou
[bd@localServer ~]$ cat cut.txt | grep "zhou" | cut -d " " -f 1
zhou
### Selection system PATH A variable's value , The first 2 individual “:” All paths after start :
[bd@localServer ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/bd/bin
#### Among them 2- It means take 2 And everything after that
[bd@localServer ~]$ echo $PATH | cut -d : -f 2-
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/bd/bin
### cutting ifconfig Post print IP Address
[bd@localServer ~]$ ifconfig eth0 | grep "inet addr" | cut -d : -f 2 | cut -d " " -f 1
192.168.1.102
版权声明
本文为[Magic Flute love]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231704450963.html
边栏推荐
猜你喜欢
Nifi fast installation and file synchronization
The new MySQL table has a self increasing ID of 20 bits. The reason is
Rtklib 2.4.3 source code Notes
Bytevcharts visual chart library, I have everything you want
Milvus 2.0 質量保障系統詳解
Change the password after installing MySQL in Linux
Node access to Alipay open platform sandbox to achieve payment function
Derivation of Σ GL perspective projection matrix
Nodejs installation and environment configuration
Shell script -- shell programming specification and variables
随机推荐
◰ GL shader handler encapsulation
Redis docker installation
Wiper component encapsulation
【WPF绑定3】 ListView基础绑定和数据模板绑定
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
VsCode-Go
线性代数感悟之2
蓝桥杯省一之路06——第十二届省赛真题第二场
Aiot industrial technology panoramic structure - Digital Architecture Design (8)
1-4 configuration executable script of nodejs installation
Nacos + aspnetcore + Ocelot actual combat code
[markdown notes]
Shell-sort命令的使用
拷贝构造函数 浅拷贝与深拷贝
Shell脚本——Shell编程规范及变量
如何用Redis实现分布式锁?
杂文 谈谈古典的《拆掉思维里的墙》
Baidu Map Case - modify map style
[PROJECT] small hat takeout (8)
Production environment——