{"id":483,"date":"2013-12-03T01:12:14","date_gmt":"2013-12-03T01:12:14","guid":{"rendered":"http:\/\/www.theSQLReport.com\/?p=483"},"modified":"2014-11-22T14:32:53","modified_gmt":"2014-11-22T14:32:53","slug":"grep-like-command-in-windows","status":"publish","type":"post","link":"https:\/\/www.theSQLReport.com\/?p=483","title":{"rendered":"Grep like command in Windows?"},"content":{"rendered":"<p style=\"text-align: left;\">In Linux &amp; Unix, I find that I use the grep command to filter the information by different utilities that returns more then a screen full of information.\u00a0 For example using netstat, normally I want to view only the connections to a certain port numbers. Below is an example in Linux.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-485\" title=\"Linux Grep Results\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find01.jpg\" alt=\"Linux Grep Results\" width=\"765\" height=\"127\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find01.jpg 765w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find01-300x49.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find01-210x34.jpg 210w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/p>\n<p style=\"text-align: left;\">I need to do the same type of filtering in the Windows Command Prompt.\u00a0 Using the Windows &#8220;<a title=\"Microsoft Windows Find Command\" href=\"http:\/\/www.microsoft.com\/resources\/documentation\/windows\/xp\/all\/proddocs\/en-us\/find.mspx?mfr=true\" target=\"_blank\">find<\/a>&#8221; command, I am able to filter the results with something similar to the grep command in Linux\/Unix.\u00a0 In the example below, I want to see only those lines from the netstat utility that have the port number 1433.\u00a0 I am able to pipe the results to the &#8220;find&#8221; command for the string 1433.<\/p>\n<p style=\"text-align: left;\"><strong>An important difference with the &#8220;find&#8221; command is that I must have my filtering string in double quotes. Example: <em>netstat -an | find &#8220;1433&#8221;<\/em><br \/>\n<\/strong><\/p>\n<div id=\"attachment_486\" style=\"width: 679px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find02.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-486\" class=\"wp-image-486 size-full\" title=\"Windows Netstat Find Results\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find02.jpg\" alt=\"Windows Netstat Find Results\" width=\"669\" height=\"128\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find02.jpg 669w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find02-210x40.jpg 210w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><\/a><p id=\"caption-attachment-486\" class=\"wp-caption-text\">netstat -an | find &#8220;1433&#8221;<\/p><\/div>\n<p style=\"text-align: left;\">The find command does not have all the functionality of the grep command.\u00a0 However 90% of what I use in the grep command, I am able to accomplish with the &#8220;find&#8221; command.\u00a0 For example,\u00a0 I am able to filter the utility &#8220;tasklist&#8221; to return only the information on the services or processes that I am interested in seeing.<\/p>\n<div id=\"attachment_487\" style=\"width: 678px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find03.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-487\" class=\"wp-image-487 size-full\" title=\"Windows Tasklist Find Results\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find03.jpg\" alt=\"Windows Tasklist Find Results\" width=\"668\" height=\"141\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find03.jpg 668w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find03-300x63.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/11\/find03-210x44.jpg 210w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/a><p id=\"caption-attachment-487\" class=\"wp-caption-text\">tasklist | find &#8220;sql&#8221;<\/p><\/div>\n<p style=\"text-align: left;\">For the Powershell Console window:<\/p>\n<div id=\"attachment_823\" style=\"width: 656px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/12\/findstr.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-823\" class=\"wp-image-823 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/12\/findstr.jpg\" alt=\"findstr\" width=\"646\" height=\"154\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/12\/findstr.jpg 646w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/12\/findstr-300x71.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/12\/findstr-210x50.jpg 210w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/a><p id=\"caption-attachment-823\" class=\"wp-caption-text\">netstat -an | findstr &#8220;1433&#8221;<\/p><\/div>\n<p style=\"text-align: left;\">In the PowerShell Console window, the find command will not work.\u00a0 The &#8220;findstr&#8221; does the same thing as the &#8220;find&#8221; in the command prompt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux &amp; Unix, I find that I use the grep command to filter the information by different utilities that returns more then a screen full of information.\u00a0 For example &hellip; <a class=\"readmore\" href=\"https:\/\/www.theSQLReport.com\/?p=483\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":486,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10],"tags":[],"class_list":["post-483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql-server","category-windows"],"_links":{"self":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/483"}],"collection":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":23,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":825,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions\/825"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/media\/486"}],"wp:attachment":[{"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}