当前位置:网站首页>The upper and lower lines of the shell are merged into one line
The upper and lower lines of the shell are merged into one line
2022-06-25 07:07:00 【mixboot】
List of articles
shell
shell The upper and lower lines are merged into one line
Preface
sed
One 、shell Two lines up and down
1.file
cat file.txt
host1
192.168.0.1
host2
192.168.0.2
host3
192.168.0.3
host4
192.168.0.4
host5
192.168.0.5
2.sed
sed 'N;s/\n/ :/' file
# cat file.txt | sed 'N;s/\n/ :/'
host1 :192.168.0.1
host2 :192.168.0.2
host3 :192.168.0.3
host4 :192.168.0.4
host5 :192.168.0.5
Two 、sed Multiple lines
N (next) Multiline operation command , The two lines before and after the text are merged into one line
# cat file.txt
host11
192.168.0.1
host222
192.168.0.2
host3
192.168.0.3
host44
192.168.0.4
host555
192.168.0.5
# sed 'N;s/\n/ :/' file.txt
host11 :192.168.0.1
host222 :192.168.0.2
host3 :192.168.0.3
host44 :192.168.0.4
host555 :192.168.0.5
- Use “ tabs ”
\tAlign edges
# sed 'N;s/\n/ \t/' file.txt
host11 192.168.0.1
host222 192.168.0.2
host3 192.168.0.3
host44 192.168.0.4
host555 192.168.0.5
Reference resources
边栏推荐
- [2022 dark horse programmer] SQL optimization
- Single lithium battery 3.7V power supply 2x12w stereo boost audio power amplifier IC combination solution
- Make fertilizer Safi from crop residues locally to increase yield by 30% and improve soil
- How to record a database [closed] - how to document a database [closed]
- 48 张图 | 手摸手教你微服务的性能监控、压测和调优
- アルマ / 炼金妹
- 赚够钱回老家吗
- レ / leilei
- MSG_ OOB MSG_ PEEK
- 【工具分享】一款颜值与技能并重的软件
猜你喜欢

【一起上水硕系列】Day 5

Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116

アルマ / alchemy girl

Derivation of COS (a+b) =cosa*cosb-sina*sinb

Acwing / 2004. Mauvaise écriture

CTFHub-Web-信息泄露-目录遍历

Flask 的入门级使用

Practice of hierarchical management based on kubesphere

Derivation of sin (a-b) =sina*cosb-sinb*cosa

joda.time获取日期总结
随机推荐
Derivation of sin (a-b) =sina*cosb-sinb*cosa
Flask 的入门级使用
Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC
Practice of hierarchical management based on kubesphere
Learn the first routine of FPGA
Common cluster scripts
Cs8683 (120W mono class D power amplifier IC)
【一起上水硕系列】Day 4
Non-contact infrared temperature measurement system for human body based on single chip microcomputer
Cloning and importing DOM nodes
shell 上下两行合并成一行
Unity get resource path
[learn shell programming easily]-5. Plan tasks
Bcrypt password encryption kalrry
燕京啤酒何以至此?
Solar orbiter captured the full picture of the largest prominence eruption in history
How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517
How to find happiness in programming and get lasting motivation?
Are you still doing the dishes yourself? Teach you how to make dishwasher controller with single chip microcomputer
Entry level use of flask