发布时间:2022-08-09 文章分类:编程知识 投稿人:赵颖 字号: 默认 | | 超大 打印

Remove Line Breaks using the stream editor sed

sed (stream editor) is a Unix utility that (a) parses text files and (b)
implements a programming language which can apply textual transformations to such files.
It reads input files line by line (sequentially), applying the operation
which has been specified via the command line (or a sed script), and then outputs the line.

(Source: Wikipedia)

With sed it's also possible to remove line breaks from a file. The following example shows, how you can
remove carriage returns from a file called test.txt:

sed -n -e ":a" -e "$ s/\n/ /gp;N;b a" test.txt