我想删除连续的重复行。即例如perl删除连续的重复行
**test.txt**
car
speed is good
bike
slower than car
plane
super fast
super fast
bullet train
super fast
这除去第一次出现以外的所有重复行。
perl -ne 'print unless $a{$_}++'
但我想在输出中是
**test.txt**
car
speed is good
bike
slower than car
plane
super fast
bullet train
super fast
我想这oneliner但这并不做任何事情,只是打印输入。
perl -00 -F'<\w+>|</\w+>' -i.bak -lane 'foreach(@F){if ($_=~/\w+/ && ($a ne $_)){print "$_";$a=$_;}}'
如何做到这一点???
如果您在Linux上(或者在Windows上使用Cygwin),请改用[uniq(1)](http://unixhelp.ed.ac.uk/CGI/man-cgi?uniq)。 –