当前位置:网站首页>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
边栏推荐
- org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
- Log4j output log information to file
- Copy constructor shallow copy and deep copy
- Solution architect's small bag - 5 types of architecture diagrams
- Linux MySQL data timing dump
- Use between nodejs modules
- Get the column name list of the table quickly in Oracle
- groutine
- Promise (I)
- PHP efficiently reads large files and processes data
猜你喜欢
SQL database
博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
Bytevcharts visual chart library, I have everything you want
Mock test using postman
Lock lock
面试百分百问到的进程,你究竟了解多少
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
How much do you know about the process of the interview
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
Lock锁
随机推荐
Paging the list collection
杂文 谈谈古典的《拆掉思维里的墙》
1-5 nodejs commonjs specification
BUG_ me
Scope and scope chain in JS
Input file upload
SQL database
Shell script -- shell programming specification and variables
PyMySQL
groutine
Camtasia2022软件新增功能介绍
深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
_ Mold_ Board_
线性代数感悟之2
网络安全之渗透靶场实战详解
AIOT产业技术全景结构-数字化架构设计(8)
Multithreaded @ async thread pool
STM32__ 03 - beginner timer
Quick install mongodb
◰ GL shadow map core steps