用换行符和“ [英] sed with newlines and "
本文介绍了用换行符和“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一堆看起来像这样的文本文件:
I have a bunch of textfile that looks like this:
His doctor attributed this to an allergy .
That hardly convinced him , as he had no history of allergies of any kind .
" Yet , that was to be the least of his problems .
I may have to take steroids for the rest of my life .
"
A topical steroid spray was later added to his repertoire of drugs and
" he knew it was merely masking the underlying condition .
"
我想更改它,以使. "
在一行中.所需的输出应如下所示:
And I want to change it such that the . "
are in a single line. The desired output should look like this:
His doctor attributed this to an allergy .
That hardly convinced him , as he had no history of allergies of any kind .
" Yet , that was to be the least of his problems .
I may have to take steroids for the rest of my life . "
A topical steroid spray was later added to his repertoire of drugs and
" he knew it was merely masking the underlying condition . "
我已经尝试过了,但是不起作用:
I've tried this but it doesn't work:
sed -i 's/.\n"\n/. "\n/g'
有人可以帮助我执行正确的sed命令来将"
向上移动吗?
Can someone help me out on the correct sed command to shift the "
up?
推荐答案
这是我想出的:
sed -n '1{h;d};/^"$/{g;s/$/ "/p;n;h;d};x;p;${g;p}' input.txt
输出
His doctor attributed this to an allergy .
That hardly convinced him , as he had no history of allergies of any kind .
" Yet , that was to be the least of his problems .
I may have to take steroids for the rest of my life . "
A topical steroid spray was later added to his repertoire of drugs and
" he knew it was merely masking the underlying condition . "
这篇关于用换行符和“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文