如何删除重复行但不排序(保持初始顺序)
How to remove repeated lines but not sorting (keep the initial order)
我有这个输入:
Host: ping.chartbeat.net
Host: extra.test.co
userblablabla
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: secure.test.com
userlalalalala
Host: ping.chartbeat.net
Host: secure.test.com
Host: secure.test.com
Host: secure.test.com
我想把它转换成这样:
Host: ping.chartbeat.net
Host: extra.test.co
userblablabla
Host: secure.test.com
userlalalalala
我该如何执行该操作?
我尝试了 |sort -u
但这打破了我想要的行的顺序
您想使用 uniq <file>
。 uniq is part of the GNU coreutils.
我有这个输入:
Host: ping.chartbeat.net
Host: extra.test.co
userblablabla
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: extra.test.co
Host: secure.test.com
userlalalalala
Host: ping.chartbeat.net
Host: secure.test.com
Host: secure.test.com
Host: secure.test.com
我想把它转换成这样:
Host: ping.chartbeat.net
Host: extra.test.co
userblablabla
Host: secure.test.com
userlalalalala
我该如何执行该操作?
我尝试了 |sort -u
但这打破了我想要的行的顺序
您想使用 uniq <file>
。 uniq is part of the GNU coreutils.