我正在努力解决这个问题,如果我能删除重复项,我会感到高兴,但他们需要连续。
输入:
This is not consecutive This is consecutive This is consecutive This is consecutive This is not consecutive
输出:
This is not consecutive This is not consecutive
答案 0 :(得分:0)
使用标准% uniq foo
This is not consecutive
This is consecutive
This is not consecutive
程序,删除连续的匹配行:
uniq
当没有参数运行时,你仍然会有一个"这是连续的"每批重复的行。但是(我承认,我今天之前并不知道这一点)-u
包含% uniq -u foo
This is not consecutive
This is not consecutive
选项,只打印不重复的行!
public void doAttackAnimation(){
new Thread(()-> {
setIcon("Your Attack Animation");
sleep(durationOfAnimation);
setIcon("default Animation");
}).start();
}
答案 1 :(得分:0)
您可以对输入进行排序,也可以使用sort
-u
选项:
$ sort -u inp
This is consecutive
This is not consecutive
或者如果原始订单很重要,您可以使用此经典awk片段:
$ awk '!a[$0]++' inp
This is not consecutive
This is consecutive
请注意,后一种解决方案将每个唯一的输入行存储在一个数组中,因此对于很长的输入文件,您可能会受到可用内存的限制。