当前位置:网站首页>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
边栏推荐
- An essay on the classical "tear down the wall in thinking"
- Milvus 2.0 质量保障系统详解
- 1-4 configuration executable script of nodejs installation
- 1-2 JSX syntax rules
- . net type transfer
- Kingdee Cloud Star API calling practice
- Bottom processing of stack memory in browser
- Further optimize Baidu map data visualization
- Tencent resolves the address according to the IP address
- Handwritten event publish subscribe framework
猜你喜欢
文件操作《二》(5000字总结篇)
Get the column name list of the table quickly in Oracle
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
Detailed explanation of the penetration of network security in the shooting range
Document operation II (5000 word summary)
1-4 configuration executable script of nodejs installation
How much do you know about the process of the interview
Milvus 2.0 質量保障系統詳解
Smart doc + Torna generate interface document
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
随机推荐
Tencent resolves the address according to the IP address
如何用Redis实现分布式锁?
Promise (III)
Wiper component encapsulation
1-3 nodejs installation list configuration and project environment
【题解】[SHOI2012] 随机树
Further optimize Baidu map data visualization
Multithreaded @ async thread pool
PostgreSQL列存与行存
websocket
Baidu Map 3D rotation and tilt angle adjustment
JSON deserialize anonymous array / object
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
PHP高效读大文件处理数据
Lock lock
Production environment——
Go language RPC communication
How much do you know about the process of the interview
Nacos + aspnetcore + Ocelot actual combat code
Rtklib 2.4.3 source code Notes