{"id":723,"date":"2020-03-12T09:41:43","date_gmt":"2020-03-12T08:41:43","guid":{"rendered":"https:\/\/blog.mhasin.eu\/?p=723"},"modified":"2020-03-12T09:58:19","modified_gmt":"2020-03-12T08:58:19","slug":"bash-uprava-textu-spocitanie-riadkov-grep-ip-zoradenie-ip-uniq","status":"publish","type":"post","link":"https:\/\/blog.mhasin.eu\/?p=723","title":{"rendered":"bash upr\u00e1va textu, spo\u010d\u00edtanie riadkov, grep IP, zoradenie IP, uniq"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Odstranenie ridkov z textoveho suboru. Zmazanie prvych 51 riadkov zo suboru:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed '1,51d' text.log > output\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Vybratie zo suboru iba IP adresy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> grep -E -o \"([0-9]{1,3}[\\.]){3}[0-9]{1,3}\" ip.log<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"72\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-15.png\" alt=\"\" class=\"wp-image-724\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-15.png 595w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-15-300x36.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Zoradenie Ip adresy podla postupnosti:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sort -t . -k 3,3n -k 4,4n  ip<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>-t .<\/strong> : Set field to . (dot) as our IPs separated by dot symbol<\/li><li><strong> -n<\/strong> : Makes the program sort according to numerical value<\/li><li><strong>-k opts<\/strong>:\n Sort data \/ fields using the given column number. For example, the \noption -k 2 made the program sort using the second column of data. The \noption -k 3,3n -k 4,4n sorts each column. First it will sort 3rd column \nand then 4th column.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image is-style-zoooom\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"67\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-16.png\" alt=\"\" class=\"wp-image-725\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-16.png 439w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/03\/obr\u00e1zok-16-300x46.png 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Spojenie unikatnych IP adries a vypisanie iba jedneho vyskitu rovakeho zaznamu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uniq -u<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div class=\"pdf24Plugin-cp\"> \t<form name=\"pdf24Form0\" method=\"post\" action=\"https:\/\/doc2pdf.pdf24.org\/wordpress.php\" target=\"pdf24PopWin\" onsubmit=\"var pdf24Win = window.open('about:blank', 'pdf24PopWin', 'resizable=yes,scrollbars=yes,width=600,height=250,left='+(screen.width\/2-300)+',top='+(screen.height\/3-125)+''); pdf24Win.focus(); if(typeof pdf24OnCreatePDF === 'function'){void(pdf24OnCreatePDF(this,pdf24Win));}\"> \t\t<input type=\"hidden\" name=\"blogCharset\" value=\"Cw1x07UAAA==\" \/><input type=\"hidden\" name=\"blogPosts\" value=\"MwQA\" \/><input type=\"hidden\" name=\"blogUrl\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLQUA\" \/><input type=\"hidden\" name=\"blogName\" value=\"c\/LxdwcA\" \/><input type=\"hidden\" name=\"blogValueEncoding\" value=\"gzdeflate base64\" \/><input type=\"hidden\" name=\"postId_0\" value=\"MzcyBgA=\" \/><input type=\"hidden\" name=\"postTitle_0\" value=\"S0oszlAoLSg6vLAsUaEktaKkVEehuCD\/SO\/htSWJeZmpCkWZiSnZ+WU6CulFqQUKngE6ClX5RYkpqSA5EK80L7MQAA==\" \/><input type=\"hidden\" name=\"postLink_0\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLdW3L7A1NzIGAA==\" \/><input type=\"hidden\" name=\"postAuthor_0\" value=\"y00syfcwNAIA\" \/><input type=\"hidden\" name=\"postDateTime_0\" value=\"MzIwMtA1MNY1NFIwsLQyMLYyMQYA\" \/><input type=\"hidden\" name=\"postContent_0\" value=\"rVVNb9s4EL37Vwx0aQJYkj8TxJB96wI9LHaBLHpot4exxEisKZLLD8Vy0R\/T37J\/bIdU6jrwtk3Q6CCK0ui9Rw7nzajQUAq0dp3c63QrVLlLNRqsDeom2fxRWWdQMskZGF7tVAcHcGzvVMcaBdZvlfEZvGvxgCFGm64vG1hOKRqH8K9RqyLXmxFdhTbsjLNUFUs2RRg2llXwajpeTqtXkSsTqoYNKO+0d6Mij0GEZtgD3o9W8LbfGnQk7SgE+BbhzZ+AlWG2f7osqA3TkL6GVEFy8X6S3nz4NB3PP7\/\/O\/tw+YnG45sEuA6iz6Xe8dr\/Dw1vsWZg+YGlAg09cpta1wuWHhRdLUngbQ1CYcVlvU4EHvoEKkbwcY62l2UC97xyzTpZ3iwTaBivG7dOrmcJWFOuk8Y5bVd5Tox11jZoucyYz0lDqaRj0uVeBwKbzyazST6Z52pr\/v1yULt0usy0rBNAQYDJifqoO72eLSKHZe4FaIDk34\/hl3DS+WSyn19FOHq8T+Lekmb0To3hosV9GjdrFdj0\/hKmk0lHrHGWQE45G1L1hBP2ThmsYoW80Q+HCrSqBNLdOq8l3fkzTr8yDlIHGaQ7mI\/nMoyL8UICnarzE+XFGZrg1hGa4JuCqlfJehPgivxhAiu4ZQ7uOBMVOEVEF5Vyl4CWSsxQZViwLKzPUR1ue6CPYPt2q0SRB8wTXEjlKezvuGMWXBN8QNHutBAXg2WpTDiogU36lhleooAOhWdnkLRYpZ09wq5GcBtAKnQI+aDagrcRjphq3jEJpRK+lQF8y0wGvykDbI+tFmwco0aEyVXcyhm0lK5zld8gLdWVrL5iqrvIncFfj3EepSYgWGBI3jf8Rhq4sQ64o6oUYqCYmyPqCImByCQs3PGfYTNyL4bUVrz7jlOc28NjY0HBa1lSkTBz4irPc5HF\/Oabi1xdv4CLXP3ERZYv4yJD2ZP8X3SRq+giiye5CLGduEicPXKRIqdkPsFLbrX6GK3ES75DJ0MzHVoVp8pC6HrNbey0oYl9ZJUMbbjr7Y47D0Z1VIH04oAHie0zWi7R\/QOpf2ZvjfD\/AQ==\" \/> \t\t<a href=\"https:\/\/www.pdf24.org\" target=\"_blank\" title=\"www.pdf24.org\" rel=\"nofollow\"><img src=\"https:\/\/blog.mhasin.eu\/wp-content\/plugins\/pdf24-post-to-pdf\/img\/pdf_32x32.png\" alt=\"\" border=\"0\" height=\"32\" \/><\/a> \t\t<span class=\"pdf24Plugin-cp-space\">\u00a0\u00a0<\/span> \t\t<span class=\"pdf24Plugin-cp-text\">Send article as PDF<\/span> \t\t<span class=\"pdf24Plugin-cp-space\">\u00a0\u00a0<\/span> \t\t<input class=\"pdf24Plugin-cp-input\" style=\"margin: 0px;\" type=\"text\" name=\"sendEmailTo\" placeholder=\"Enter email address\" \/> \t\t<input class=\"pdf24Plugin-cp-submit\" style=\"margin: 0px;\" type=\"submit\" value=\"Send\" \/> \t<\/form> <\/div>","protected":false},"excerpt":{"rendered":"Odstranenie ridkov z textoveho suboru. Zmazanie prvych 51 riadkov zo suboru: Vybratie zo suboru iba IP adresy: Zoradenie Ip adresy podla postupnosti: -t . : Set field to . (dot) as our IPs separated by dot symbol -n : Makes the program sort according to numerical value -k opts: Sort data \/ fields using the given column number. For example, the option -k 2 made the program sort using the second column of data. The&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"arc_restricted_post":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-723","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=723"}],"version-history":[{"count":3,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/723\/revisions"}],"predecessor-version":[{"id":728,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/723\/revisions\/728"}],"wp:attachment":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}