当前位置:网站首页>Use of shell sed command
Use of shell sed command
2022-04-23 17:06:00 【Magic Flute love】
sed
sed Is a flow editor , It processes one line at a time . When dealing with , Store the currently processed rows in a temporary buffer , be called “ Mode space ”, Then use sed Command processing buffer contents , After processing , Send the contents of the buffer to the screen . Next line , This is repeated , Until the end of the file . The contents of the document have not changed , Unless you use redirected storage output .
Basic usage
sed [ Option parameters ] 'command' filename
Option parameter description
| Option parameters | function |
|---|---|
| -e | Directly in command line mode sed Action editor . |
Common command function description
| command | Function description |
|---|---|
| a | newly added ,a You can use a string after , On the next line |
| d | Delete |
| s | Find and replace |
Case practice
# Data preparation
[bd@localServer ~]$ touch sed.txt
[bd@localServer ~]$ vim sed.txt
fu xia
zhou men
wo wo
lai lai
le le
### take “wo shi” This word is inserted into sed.txt Second elements , Print .
[bd@localServer ~]$ sed '2a wo shi' sed.txt
fu xia
zhou men
wo shi
wo wo
lai lai
le le
#### The source file has not changed
[bd@localServer ~]$ cat sed.txt
fu xia
zhou men
wo wo
lai lai
le le
### Delete sed.txt All files contain wo The line of
[bd@localServer ~]$ sed '/wo/d' sed.txt
fu xia
zhou men
lai lai
le le
### take sed.txt In file wo Replace with ni,g Express global For global operations , If not, only the first one
[bd@localServer ~]$ sed 's/wo/ni/g' sed.txt
fu xia
zhou men
ni ni
lai lai
le le
### take sed.txt The second line in the file is deleted and the wo Replace with ni
[bd@localServer ~]$ sed -e '2d' -e 's/wo/ni/g' sed.txt
fu xia
ni ni
lai lai
le le
版权声明
本文为[Magic Flute love]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231704450922.html
边栏推荐
- The new MySQL table has a self increasing ID of 20 bits. The reason is
- Sub database and sub table & shardingsphere
- ClickHouse-表引擎
- Freecodecamp ---- budget & category exercise
- PHP高效读大文件处理数据
- Derivation of Σ GL perspective projection matrix
- Baidu Map 3D rotation and tilt angle adjustment
- Go language, array, string, slice
- Calculation formula related to tolerance analysis
- 正则过滤内网地址和网段
猜你喜欢

Detailed explanation of C webpai route

Detailed explanation of the penetration of network security in the shooting range
![[registration] tf54: engineer growth map and excellent R & D organization building](/img/12/7aece45fbc9643c97cdda94b405118.jpg)
[registration] tf54: engineer growth map and excellent R & D organization building

网络安全之渗透靶场实战详解

JS, entries(), keys(), values(), some(), object Assign() traversal array usage

Idea of batch manufacturing test data, with source code

Document operation II (5000 word summary)

Lock lock

Quick install mongodb

Feign report 400 processing
随机推荐
. net cross platform principle (Part I)
STM32__03—初识定时器
Baidu Map Case - modify map style
如何用Redis实现分布式锁?
Milvus 2.0 质量保障系统详解
Zhimeng dedecms security setup Guide
Sub database and sub table & shardingsphere
1-4 configuration executable script of nodejs installation
Shell-入门、变量、以及基本的语法
AIOT产业技术全景结构-数字化架构设计(8)
Promise (I)
Milvus 2.0 détails du système d'assurance de la qualité
MySQL master-slave configuration under CentOS
Detailed explanation of Milvus 2.0 quality assurance system
【题解】[SHOI2012] 随机树
El cascade and El select click elsewhere to make the drop-down box disappear
文件操作《二》(5000字总结篇)
Nifi fast installation and file synchronization
Regular filtering of Intranet addresses and segments
JS to find the character that appears three times in the string