当前位置:网站首页>Shell-cut命令的使用
Shell-cut命令的使用
2022-04-23 17:04:00 【魔笛Love】
cut
cut的工作就是“剪”,具体的说就是在文件中负责剪切数据用的。
cut 命令从文件的每一行剪切字节、字符和字段并将这些字节、字符和字段输出。cut之后并没有改变原来的值
基本用法
cut [选项参数] filename
说明:默认分隔符是制表符(\t)
选项参数说明
选项参数 | 功能 |
---|---|
-f | 列号,提取第几列 |
-d | 分隔符,按照指定分隔符分割列 |
案例实操
##数据准备
[bd@localServer ~]$ touch cut.txt
[bd@localServer ~]$ vim cut.txt
fu xia
zhou men
wo wo
lai lai
le le
### 切割cut.txt第一列
[bd@localServer ~]$ cut -d " " -f 1 cut.txt
fu
zhou
wo
lai
le
### 切割cut.txt第二、三列
[bd@localServer ~]$ cut -d " " -f 2,3 cut.txt
xia
men
wo
lai
le
### 在cut.txt文件中切割出zhou
[bd@localServer ~]$ cat cut.txt | grep "zhou" | cut -d " " -f 1
zhou
### 选取系统PATH变量值,第2个“:”开始后的所有路径:
[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
#### 其中的2-表示取2以及之后所有的
[bd@localServer ~]$ echo $PATH | cut -d : -f 2-
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/bd/bin
### 切割ifconfig 后打印的IP地址
[bd@localServer ~]$ ifconfig eth0 | grep "inet addr" | cut -d : -f 2 | cut -d " " -f 1
192.168.1.102
版权声明
本文为[魔笛Love]所创,转载请带上原文链接,感谢
https://blog.csdn.net/clearlxj/article/details/121742555
边栏推荐
- 自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
- Production environment——
- 【WPF绑定3】 ListView基础绑定和数据模板绑定
- Go language, array, string, slice
- ◰ GL shader handler encapsulation
- Nodejs installation and environment configuration
- 拷贝构造函数 浅拷贝与深拷贝
- 面试百分百问到的进程,你究竟了解多少
- org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
- Getting started with JDBC
猜你喜欢
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
Milvus 2.0 质量保障系统详解
博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
Idea of batch manufacturing test data, with source code
True math problems in 1959 college entrance examination
Bytevcharts visual chart library, I have everything you want
Installing labellmg tutorial in Windows
. net type transfer
Derivation of Σ GL perspective projection matrix
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
随机推荐
1-2 characteristics of nodejs
[markdown notes]
Go language, array, string, slice
Bottom processing of stack memory in browser
Feign report 400 processing
计算饼状图百分比
Nifi fast installation and file synchronization
1-3 components and modules
1-3 nodejs installation list configuration and project environment
[registration] tf54: engineer growth map and excellent R & D organization building
◰ GL shadow map core steps
Tencent resolves the address according to the IP address
[C#] 彻底搞明白深拷贝
. net cross platform principle (Part I)
Baidu Map Case - modify map style
文件操作《二》(5000字总结篇)
杂文 谈谈古典的《拆掉思维里的墙》
Wiper component encapsulation
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
Redis docker installation