当前位置:网站首页>shell 上下两行合并成一行
shell 上下两行合并成一行
2022-06-25 06:38:00 【mixboot】
系列文章目录
shell
前言
sed
一、shell上下两行
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
二、sed多行
N (next)多行操作命令,文本前后两行合并为一行
# 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
- 使用“制表符”
\t
对齐边缘
# 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
参考
边栏推荐
- Navicat防止新建查询误删
- 【2022黑马程序员】SQL优化
- Analysis on the output, market scale and development status of China's children's furniture industry in 2020 and the competition pattern of children's furniture enterprises [figure]
- Blue Bridge Cup SCM module code (external interrupt) (code + comment)
- [从零开始学习FPGA编程-43]:视野篇 - 后摩尔时代”芯片设计的技术演进-2-演进方向
- Non-contact infrared temperature measurement system for human body based on single chip microcomputer
- The significance and proof of weak large number theorem
- Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
- Ht81293 built in adaptive dynamic boost 20W mono class D power amplifier IC solution
- What is cloud primordial?
猜你喜欢
Esp8266 & sg90 steering gear & Lighting Technology & Arduino
Want to self-study SCM, do you have any books and boards worth recommending?
Analysis on the output, market scale and development status of China's children's furniture industry in 2020 and the competition pattern of children's furniture enterprises [figure]
joda. Time get date summary
Capable people never complain about the environment!
アルマ / 炼金妹
Cs4344/ht5010 stereo d/a digital to analog converter
Entry level use of flask
[core content and derivation] the mystery of human memory system may be just like this
高效探索|ES地理位置查询的一次应用实践
随机推荐
[learn shell programming easily]-5. Plan tasks
【xxl-job】池塘水绿风微暖,记得玉真初见面
cos(a-b)=cosa*cosb+sina*sinb的推导过程
Direct select sort and quick sort
The process of making wooden barrels with 3DMAX software: a three-step process
Design of PWM breathing lamp based on FPGA
Kubernetes core components etcd details
How to record a database [closed] - how to document a database [closed]
Derivation of sin (a+b) =sina*cosb+sinb*cosa
Make fertilizer Safi from crop residues locally to increase yield by 30% and improve soil
有能力的人从不抱怨大环境!
The significance and proof of weak large number theorem
使用OpenGL绘制shp文件
Acwing / 2004. Mauvaise écriture
Ht513 I2S input 2.8W mono class D audio power amplifier IC
Controlling volume mixer
[Shangshui Shuo series] day 5
Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)
Solar orbiter captured the full picture of the largest prominence eruption in history
Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116