以specifc字符串开头的上线
如果字符串从特定的单词开始,该如何排队?
文件:
My name
is kuku
My name
is pupu
My name
is yoyo
输出应该是:
My name is kuku
My name is pupu
My name is yoyo
我尝试了以下命令,但看我缺少一些东西...
sed s=^is=\r is=g' file
How can I take line up if string start with a specific word?
file:
My name
is kuku
My name
is pupu
My name
is yoyo
Output should be:
My name is kuku
My name is pupu
My name is yoyo
I tried the below command but look I'm missing something...
sed s=^is=\r is=g' file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个
awk
基于基于的解决方案,根本不需要使用任何数学,只使用内置变量,而无需进行:input
code
输出
最冷凝的版本,如果您不关心
fs
效率,Here's an
awk
-based solution that doesn't require doing any math at all, using only built-in variables and nothing else:INPUT
CODE
OUTPUT
The most condensed edition, if you don't care for
FS
efficiency, would beawk 是您的朋友:
来源:
https://stackoverflow.com/questions/questions/ 8545538/how-do-do-join-pairs in-a-a-a-a-a-a-a-a-a in-a-a-large-file-file-file-1亿英寸 - uses-使用
英语:
通过文件迭代
记住它,跳过
其他
粘贴记忆的线与当前(IE偶数)线被空间分隔
awk is your friend:
Source:
https://stackoverflow.com/questions/8545538/how-do-i-join-pairs-of-consecutive-lines-in-a-large-file-1-million-lines-using
In English:
Iterate through the file
If the line number is odd
remember it and skip
Else
paste remembered line with the current (i.e. even) line separated by space