当前位置:网站首页>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
边栏推荐
- Website_ Collection
- Collect blog posts
- An essay on the classical "tear down the wall in thinking"
- Promise (II)
- 蓝桥杯省一之路06——第十二届省赛真题第二场
- JS to find the character that appears three times in the string
- . net cross platform principle (Part I)
- Change the password after installing MySQL in Linux
- STM32__ 03 - beginner timer
- 文件操作《二》(5000字总结篇)
猜你喜欢

Use between nodejs modules

On lambda powertools typescript

PyMySQL

feign报400处理

Rtklib 2.4.3 source code Notes

Zhongang Mining: Fluorite Flotation Process

Smart doc + Torna generate interface document

【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明

Nodejs installation and environment configuration

CentOS MySQL multi instance deployment
随机推荐
Shortcut keys (multiline)
JS, entries(), keys(), values(), some(), object Assign() traversal array usage
Multithreaded @ async thread pool
Zhongang Mining: Fluorite Flotation Process
Node access to Alipay open platform sandbox to achieve payment function
Document operation II (5000 word summary)
EF core in ASP Generate core priority database based on net entity model
VsCode-Go
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
Redis docker installation
PyMySQL
织梦DEDECMS安全设置指南
Read a blog, re understand closures and tidy up
Go language RPC communication
【解决报错】Error in v-on handler: “TypeError: Cannot read property ‘resetFields’ of undefined”
Preliminary understanding of promse
如何用Redis实现分布式锁?
[PROJECT] small hat takeout (8)
The new MySQL table has a self increasing ID of 20 bits. The reason is
Generate random numbers with high quality and Gaussian distribution