浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Remove Line Breaks - Removing line breaks using sed

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
  
posted on 2012-03-27 23:14  lexus  阅读(278)  评论(0编辑  收藏  举报