How do I convert multiple lines to one line in Linux?

Pham Quỳnh

New member
How do I convert multiple lines to one line in Linux?
Answer
Simply put, the idea of this sed one-liner is: append each line into the pattern space, at last replace all line breaks with the given string.
  1. :a; – we define a label called a.
  2. N; – append next line into sed’s pattern space.
  3. $! …
  4. s/n/REPLACEMENT/g – replace all line breaks with the given REPLACEMENT.
 

Tìm kiếm

Back
Top