-1

我有这段文字:

Mary lives in a big ci-
ty near the most beati-
ful mountains in tne coun-
try.

如何将其转换为:

Mary lives in a big city near the most beatiful mountains in tne country.

使用 perl

4

2 回答 2

2

使用 perl 单线:

perl -pe 's/-\n//' file

开关

  • -i<>:就地编辑文件(如果提供扩展名,则进行备份)
  • -p:为输入文件中的每个“行”创建一个while(<>){...; print}循环。
  • -e: 告诉perl在命令行上执行代码。
于 2014-08-26T21:21:54.613 回答
0

有时您可能需要考虑 CRLF,尤其是在使用较小的操作系统时(呵呵)。我尝试使东西尽可能便携。

s/-[\r\n]+//g

我把'+'放在那里,以防连字符和文本的其余部分之间有一个额外的空白行。

于 2014-08-28T02:35:01.250 回答