当前位置:网站首页>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
边栏推荐
- About stream flow, write it down briefly------
- Baidu Map 3D rotation and tilt angle adjustment
- VsCode-Go
- How vscode compares the similarities and differences between two files
- ClickHouse-数据类型
- [problem solving] [show2012] random tree
- Baidu Map Case - modify map style
- RTKLIB 2.4.3源码笔记
- Feign report 400 processing
- Net standard
猜你喜欢
JS, entries(), keys(), values(), some(), object Assign() traversal array usage
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
Node access to Alipay open platform sandbox to achieve payment function
SQL database
Nacos + aspnetcore + Ocelot actual combat code
扫码登录的原理你真的了解吗?
CentOS MySQL multi instance deployment
Detailed explanation of the penetration of network security in the shooting range
线性代数感悟之2
Go language, array, string, slice
随机推荐
How vscode compares the similarities and differences between two files
Getting started with JDBC
Bottom processing of stack memory in browser
1-5 nodejs commonjs specification
手写事件发布订阅框架
网络安全之渗透靶场实战详解
1-3 nodejs installation list configuration and project environment
SQL database
Scope and scope chain in JS
1-1 NodeJS
Shell-sort命令的使用
_ Mold_ Board_
1-4 configuration executable script of nodejs installation
Promise (IV)
PyMySQL
Talk about browser cache control
1-2 characteristics of nodejs
Lock锁
扫码登录的原理你真的了解吗?
How much do you know about the process of the interview