{"id":315,"date":"2008-05-03T12:27:26","date_gmt":"2008-05-03T12:27:26","guid":{"rendered":"http:\/\/gaisan.com\/wordp\/?p=315"},"modified":"2009-12-19T23:35:07","modified_gmt":"2009-12-19T23:35:07","slug":"favourite-unix-commands-uniq","status":"publish","type":"post","link":"https:\/\/gaisan.com\/blogs\/?p=315","title":{"rendered":"favourite UNIX commands, uniq"},"content":{"rendered":"<p>One of my favourites is the <code>uniq<\/code> command. The command enables you to report or omit repeated lines in a file.Here&#8217;s some switch details from the man page.<br \/>\n<code><br \/>\n-c, --count<br \/>\nprefix lines by the number of occurrences<br \/>\n-d, --repeated<br \/>\nonly print duplicate lines<br \/>\n-u, --unique<br \/>\nonly print unique lines<br \/>\n<\/code><br \/>\nSo if you wanted to find and sort common lines in two files you could do something like.<br \/>\n<code># cat file1 file2 ! uniq -d | sort<\/code><br \/>\nQuite a few friends have been asked to do something similar in interviews. I always find that a bit funny as it takes a minute to look this stuff up online so it&#8217;s probably not crucial to know every Unix command off the top of your head. Although there&#8217;s probably some nerdy bragging rights but with a 96% nerd test score I think I&#8217;ll pass.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my favourites is the uniq command. The command enables you to report or omit repeated lines in a file.Here&#8217;s some switch details from the man page. -c, &#8211;count prefix lines by the number of occurrences -d, &#8211;repeated only print duplicate lines -u, &#8211;unique only print unique lines So if you wanted to find [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1700],"_links":{"self":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/315"}],"collection":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":2,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":486,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions\/486"}],"wp:attachment":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}