{"id":1214,"date":"2019-04-28T23:33:57","date_gmt":"2019-04-28T15:33:57","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=1214"},"modified":"2022-06-05T16:32:46","modified_gmt":"2022-06-05T08:32:46","slug":"uniq","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/uniq","title":{"rendered":"uniq\u547d\u4ee4 – \u53bb\u9664\u6587\u4ef6\u4e2d\u7684\u91cd\u590d\u5185\u5bb9\u884c"},"content":{"rendered":"\n

uniq\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u5355\u8bcdunique\u7684\u7f29\u5199\uff0c\u4e2d\u6587\u8bd1\u4e3a\u72ec\u7279\u7684\u3001\u552f\u4e00\u7684\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u53bb\u9664\u6587\u4ef6\u4e2d\u7684\u91cd\u590d\u5185\u5bb9\u884c\u3002uniq\u547d\u4ee4\u80fd\u591f\u53bb\u9664\u6389\u6587\u4ef6\u4e2d\u76f8\u90bb\u7684\u91cd\u590d\u5185\u5bb9\u884c\uff0c\u5982\u679c\u4e24\u7aef\u76f8\u540c\u5185\u5bb9\u4e2d\u95f4\u5939\u6742\u4e86\u5176\u4ed6\u6587\u672c\u884c\uff0c\u5219\u9700\u8981\u5148\u4f7f\u7528sort\u547d\u4ee4\u8fdb\u884c\u6392\u5e8f\u540e\u518d\u53bb\u91cd\u590d\uff0c\u8fd9\u6837\u4fdd\u7559\u4e0b\u6765\u7684\u5185\u5bb9\u5c31\u90fd\u662f\u552f\u4e00\u7684\u4e86\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>uniq [\u53c2\u6570] \u6587\u4ef6<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-c<\/td>\u6253\u5370\u6bcf\u884c\u5728\u6587\u672c\u4e2d\u91cd\u590d\u51fa\u73b0\u7684\u6b21\u6570<\/td><\/tr>
-d<\/td>\u6bcf\u4e2a\u91cd\u590d\u7eaa\u5f55\u53ea\u51fa\u73b0\u4e00\u6b21<\/td><\/tr>
-u<\/td>\u53ea\u663e\u793a\u6ca1\u6709\u91cd\u590d\u7684\u7eaa\u5f55<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u5bf9\u6307\u5b9a\u7684\u6587\u4ef6\u8fdb\u884c\u53bb\u91cd\u64cd\u4f5c\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# cat testfile <\/strong>\ntest 30  \ntest 30  \ntest 30  \nHello 95  \nHello 95  \nHello 95  \nHello 95  \nLinux 85\nLinux 85\n[root@linuxcool ~]# uniq testfile <\/strong>\ntest 30  \nHello 95  \nLinux 85<\/pre>\n\n\n\n

\u7edf\u8ba1\u76f8\u540c\u5185\u5bb9\u884c\u5728\u6587\u4ef6\u4e2d\u91cd\u590d\u51fa\u73b0\u7684\u6b21\u6570\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# uniq -c testfile <\/strong>\n3 test 30  \n4 Hello 95  \n2 Linux 85<\/pre>\n\n\n\n

\u4ec5\u663e\u793a\u6307\u5b9a\u6587\u4ef6\u4e2d\u5b58\u5728\u4e00\u6478\u4e00\u6837\u5185\u5bb9\u884c\u7684\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# uniq -d testfile <\/strong>\ntest 30  \nHello 95  \nLinux 85<\/pre>\n\n\n\n

\u4ec5\u663e\u793a\u6307\u5b9a\u6587\u4ef6\u4e2d\u6ca1\u6709\u5b58\u5728\u4e00\u6478\u4e00\u6837\u5185\u5bb9\u884c\u7684\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# uniq -u testfile <\/strong>\n[root@linuxcool ~]# <\/pre>\n","protected":false},"excerpt":{"rendered":"

uniq\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u5355\u8bcdunique\u7684\u7f29\u5199\uff0c\u4e2d\u6587\u8bd1\u4e3a\u72ec\u7279\u7684\u3001\u552f\u4e00\u7684\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u53bb\u9664\u6587\u4ef6\u4e2d\u7684\u91cd\u590d\u5185\u5bb9\u884c\u3002un […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1214"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=1214"}],"version-history":[{"count":13,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1214\/revisions"}],"predecessor-version":[{"id":10236,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/1214\/revisions\/10236"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=1214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=1214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}