如何将多行上的文件合并为一个大行?


1

我有这样的事情:

a line here;
a new line here;
another line here;

我希望它就像是,所有的线都组合成一条线。

a line here;a new line here;another line here;

Answers:


3

tr -d '\n' <filename> 将删除给定文件中的所有换行符。


1
为了这么简单的事情而不诉诸perl的+1。
mkaito


1

(以防Windows上有人需要这个。)在PowerShell中它是

-join (Get-Content filename)

或更短:

-join(gc filename)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.