当前位置:网站首页>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
参考
边栏推荐
- 使用OpenGL绘制shp文件
- 了解zbrush雕刻软件,以及游戏建模的分析
- In a single-page app, what is the right way to deal with wrong URLs (404 errors)?
- StreamNative Platform 1.5 版本发布,集成 Istio、支持 OpenShift 部署
- Are these old system codes written by pigs?
- DataX tutorial (09) - how does dataX achieve speed limit?
- cos(a+b)=cosa*cosb-sina*sinb的推导过程
- 【xxl-job】池塘水绿风微暖,记得玉真初见面
- 父爱的表达方式
- レレ / 蕾蕾
猜你喜欢

Ctfhub web information disclosure directory traversal

弱大数定理的意义与证明

Acwing / 2004. Mauvaise écriture

sin(a-b)=sina*cosb-sinb*cosa的推导过程

Esp8266 & sg90 steering gear & Lighting Technology & Arduino

After unplugging the network cable, does the original TCP connection still exist?

基于 KubeSphere 的分级管理实践

StreamNative Platform 1.5 版本发布,集成 Istio、支持 OpenShift 部署

DataX tutorial (09) - how does dataX achieve speed limit?

レ / leilei
随机推荐
レレ / 蕾蕾
Derivation of COS (a+b) =cosa*cosb-sina*sinb
Blue Bridge Cup SCM module code (timer) (code + comments)
Zero foundation wants to learn web security, how to get started?
Understand ZBrush carving software and game modeling analysis
【ROS2】为什么要使用ROS2?《ROS2系统特性介绍》
ASP. Net core - Safety of asynclocal in asp NET Core
STL map的用法
Tp6 interface returns three elements
The Rust Programming Language
TorchServe避坑指南
Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
ACWING/2004. Misspelling
Your local changes to the following files would be overwritten by merge: . vs/slnx. sqlite
Cs8683 (120W mono class D power amplifier IC)
sin(a+b)=sina*cosb+sinb*cosa的推导过程
Blue Bridge Cup SCM module code (external interrupt) (code + comment)
Query process of MySQL secondary index
Qcom--lk phase I2C interface configuration scheme -i2c6
Why did Yanjing Beer come here?