说明:过滤换行符确实有点吭,不是那么好弄.处理文本时需要将换行符替换为空格,若使用sed命令会比较麻烦,而使用tr命令非常方便. 输入文本(country.txt) China America France German sed命令 cat country.txt | sed ':label;N;s/\n/ /;b label' tr命令 cat country.txt | tr "\n" " " 两个命令输出一致,但是sed命令的输出结尾有换行符,而tr命令的输出
A carriage return linefeed (CRLF) is a special sequence of characters, used by DOS/Windows, to signify the end of a line of text. However, in *nix, only a linefeed (LF) is required to signify a line ending. test.CRLF.txt 12345CRLF 12345LF Delete/Repl