基于模式加入线 [英] Join lines based on pattern

查看:98
本文介绍了基于模式加入线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下文件:

test
1
My
2
Hi
3

我需要一种方法来使用cat,grep或者awk来给下面的输出:

i need a way to use cat ,grep or awk to give the following output:

test1
My2
Hi3

我怎样才能在一个命令实现这一目标?像

How can i achieve this in a single command? something like

cat file.txt | grep ... | awk ...

请注意,它始终是一个字符串,然后在原来的文本文件中的一个数字。

Note that its always a string followed by a number in the original text file.

推荐答案

的sed'N; S / \\ n //'file.txt的

此应得到所需的输出时,内容是在file.txt的

This should give the desired output when the content is in file.txt

这篇关于基于模式加入线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆