在文本文件中,我需要删除与下一行完全相同的行。请参见下面的示例。
输入:
I like
I like apples
I like apples and oranges
more
more everyday
more everyday
more everyday the more
more everyday the more I play
I
I like
输出:
I like apples and oranges
more everyday the more I play
I like
一种方法:
$ perl -lne 'print $last unless /^\Q$last/; $last = $_;
END { print $last }' input.txt
I like apples and oranges
more everyday the more I play
I like