【发布时间】:2017-01-13 17:52:32
【问题描述】:
我有一个大文本文件,其中仅包含 1 行。它看起来像这样:
blaalibababla.ru text text text text what's the weather like tooday? blaazzabla.zu some_text blabewdwefla.au it is important not to be afraid of sed blabkrlqbla.ru wjenfkn lkwnef lkwnefl blarthrthbla.net 1234 e12edq 42wsdfg blablabla.com this should finally end
我需要一种方法让它看起来像这样:
blaalibababla.ru text text text text what's the weather like tooday?
blaazzabla.zu some_text
blabewdwefla.au it is important not to be afraid of sed
blabkrlqbla.ru wjenfkn lkwnef lkwnefl
blarthrthbla.net 1234 e12edq 42wsdfg
blablabla.com this should finally end
我知道如何使用单个域名和sed:
sed -i 's/blablabla.ru/\n&/g' file.txt
“但不是在之后的附加文本中。” - 我不是这个意思。
如果sed 不是最好的方法,请告诉我。
更新: 这是我的文本文件:
wsd.qwd.qwd.kjqnwk.ru PUPPETD CRITICAL 2017-01-13 00:09:52 lor notify-by-sms FILE_AGE CRITICAL: /var/lib/puppet/state/state.yaml is 2438046 seconds old and 19459 bytes zm-goas-04.asdg.net LOAD CRITICAL 2017-01-13 00:10:32 tech-lor notify-by-telegram CRITICAL - load average: 42.91, 49.91, 53.88 glas07.kvm.ext.asdg.ru PUPPETD CRITICAL 2017-01-13 00:28:02 lor notify-by-sms FILE_AGE CRITICAL: /var/lib/puppet/state/state.yaml is 19821 seconds old and 26337 bytes
我需要它看起来像:
wsd.qwd.qwd.kjqnwk.ru PUPPETD CRITICAL 2017-01-13 00:09:52 lor notify-by-sms FILE_AGE CRITICAL: /var/lib/puppet/state/state.yaml is 2438046 seconds old and 19459 bytes
zm-goas-04.asdg.net LOAD CRITICAL 2017-01-13 00:10:32 tech-lor notify-by-telegram CRITICAL - load average: 42.91, 49.91, 53.88
glas07.kvm.ext.asdg.ru PUPPETD CRITICAL 2017-01-13 00:28:02 lor notify-by-sms FILE_AGE CRITICAL: /var/lib/puppet/state/state.yaml is 19821 seconds old and 26337 bytes
【问题讨论】:
-
你能举一些实际数据作为例子吗?我很好奇
some_text到底长什么样。 -
请用你的代码编辑