当前位置:网站首页>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
边栏推荐
- Tencent resolves the address according to the IP address
- Mock test
- About stream flow, write it down briefly------
- STM32__03—初识定时器
- Milvus 2.0 détails du système d'assurance de la qualité
- C# Task. Delay and thread The difference between sleep
- feign报400处理
- How to implement distributed locks with redis?
- MySQL restores data through binlog file
- Quick install mongodb
猜你喜欢
Rtklib 2.4.3 source code Notes
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
Lock lock
Do you really understand the principle of code scanning login?
Zhongang Mining: Fluorite Flotation Process
CentOS MySQL multi instance deployment
Net standard
oracle 中快速获取表的列名列表
线性代数感悟之2
Shell脚本——Shell编程规范及变量
随机推荐
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Collect blog posts
Nodejs installation and environment configuration
Promise (III)
Shell-入门、变量、以及基本的语法
AIOT产业技术全景结构-数字化架构设计(8)
织梦DEDECMS安全设置指南
Mock test
Redis docker installation
VsCode-Go
1-3 nodejs installation list configuration and project environment
El cascade and El select click elsewhere to make the drop-down box disappear
Lock锁
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
EF core in ASP Generate core priority database based on net entity model
JS to find the character that appears three times in the string
Wiper component encapsulation
Shell-sort命令的使用
Shell脚本——Shell编程规范及变量
VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN