Linux command to merge multiple lines of text into a single line

commandpaste

  • -s: Combine multiple lines of text into a single line
  • -d ' ': Specify the delimiter as a space

Example usage

  • multiline text
line 1
line 2
line 3

Run command

cat file.txt | paste -s -d ' '

Output results

line 1 line 2 line 3

Guess you like

Origin blog.csdn.net/u010953692/article/details/132314957
Recommended