当前位置:网站首页>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
边栏推荐
- 网络安全之渗透靶场实战详解
- Do you really understand the principle of code scanning login?
- Document operation II (5000 word summary)
- How to implement distributed locks with redis?
- Variable length parameter__ VA_ ARGS__ Macro definitions for and logging
- Lock锁
- How much do you know about the process of the interview
- Bytevcharts visual chart library, I have everything you want
- Freecodecamp ---- budget & category exercise
- Milvus 2.0 質量保障系統詳解
猜你喜欢
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
PyMySQL
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Installing labellmg tutorial in Windows
Node access to Alipay open platform sandbox to achieve payment function
Milvus 2.0 détails du système d'assurance de la qualité
ByteVCharts可视化图表库,你想要的我都有
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
JS, entries(), keys(), values(), some(), object Assign() traversal array usage
随机推荐
AIOT产业技术全景结构-数字化架构设计(8)
. net cross platform principle (Part I)
◰GL-阴影贴图核心步骤
PostgreSQL column storage and row storage
Get the column name list of the table quickly in Oracle
信息摘要、数字签名、数字证书、对称加密与非对称加密详解
Regular filtering of Intranet addresses and segments
Generate random numbers with high quality and Gaussian distribution
Feign report 400 processing
MySQL master-slave replication
SPC introduction
Baidu Map Case - Zoom component, map scale component
How vscode compares the similarities and differences between two files
Basic case of Baidu map
ASP. Net core reads the configuration file in the class library project
Introduction to new functions of camtasia2022 software
Paging the list collection
手写事件发布订阅框架
线性代数感悟之2
Aiot industrial technology panoramic structure - Digital Architecture Design (8)