{"id":994,"date":"2017-09-01T11:26:28","date_gmt":"2017-09-01T09:26:28","guid":{"rendered":"http:\/\/dety.net.ua\/?p=994"},"modified":"2017-09-01T11:26:28","modified_gmt":"2017-09-01T09:26:28","slug":"extract-a-text-between-delimiters-with-sh-instead-of-using-regex","status":"publish","type":"post","link":"https:\/\/dety.net.ua\/?p=994","title":{"rendered":"Extract a text between delimiters with sh instead of using regex"},"content":{"rendered":"<p>Example file:<\/p>\n<blockquote><p>UNKNOWN[123.21.181.4]<br \/>\nabts-tn-dynamic-161.155.174.122.airtelbroadband.in[122.174.155.161]<br \/>\nfm-dyn-118-137-18-160.fast.net.id[118.137.18.160]<br \/>\nUNKNOWN[118.69.71.76]<br \/>\nip-177.71.93.43.juniornet.psi.br[177.71.93.43]<br \/>\nUNKNOWN[210.245.34.254]<br \/>\nUNKNOWN[185.140.242.41]<\/p><\/blockquote>\n<p>I want to extract IP-addresses:<\/p>\n<p>command shell:<\/p>\n<blockquote><p>cat drop.txt | cut -d'[&#8216; -f2 | cut -d&#8217;]&#8217; -f1<\/p><\/blockquote>\n<ol>\n<li>Get data from the file<\/li>\n<li>Delete all the text before the delimeter (we choose the text after the delimiter)<\/li>\n<li>Delete alle the text after the delimeter ( &#8230; before the delimeter)<\/li>\n<\/ol>\n<p>The result:<\/p>\n<blockquote><p>123.21.181.4<br \/>\n122.174.155.161<br \/>\n118.137.18.160<br \/>\n118.69.71.76<br \/>\n177.71.93.43<br \/>\n210.245.34.254<br \/>\n185.140.242.41<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Example file: UNKNOWN[123.21.181.4] abts-tn-dynamic-161.155.174.122.airtelbroadband.in[122.174.155.161] fm-dyn-118-137-18-160.fast.net.id[118.137.18.160] UNKNOWN[118.69.71.76] ip-177.71.93.43.juniornet.psi.br[177.71.93.43] UNKNOWN[210.245.34.254] UNKNOWN[185.140.242.41] I want to extract IP-addresses: command shell: cat drop.txt | cut -d'[&#8216; -f2 | cut -d&#8217;]&#8217; -f1 Get data from the file Delete all the text before the delimeter (we choose the text after the delimiter) Delete alle the text after the delimeter ( &#8230; before [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,13],"tags":[],"class_list":["post-994","post","type-post","status-publish","format-standard","hentry","category-linux","category-novosti"],"_links":{"self":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=994"}],"version-history":[{"count":1,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/994\/revisions"}],"predecessor-version":[{"id":995,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/994\/revisions\/995"}],"wp:attachment":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}