通过庆典/ AWK / Sed / Perl进行删除特定的文本后,新行 [英] Removing new line after a particular text via bash/awk/sed/perl
本文介绍了通过庆典/ AWK / Sed / Perl进行删除特定的文本后,新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除所有发生的换行符一个partiular字符串后面,并用标签空格替换它。例如说我sample.txt的是如下:
I would like to remove all the newline character that occurs after a partiular string and replace it with a tab space. Say for instance my sample.txt is as follows
foo
bar bar bar bar some text
我想它是
foo bar bar bar bar some text
如何通过bash中做到这一点/ AWK / SED。做帮助。
How do I do this via bash/awk/sed. Do help.
推荐答案
在awk的:
awk '/foo$/ { printf("%s\t", $0); next } 1'
这篇关于通过庆典/ AWK / Sed / Perl进行删除特定的文本后,新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文