{"id":412,"date":"2009-09-27T21:51:07","date_gmt":"2009-09-27T19:51:07","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=412"},"modified":"2021-06-01T13:55:36","modified_gmt":"2021-06-01T11:55:36","slug":"findstr-an-alternative-to-grep","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html","title":{"rendered":"Findstr, a Native Alternative to grep in Windows"},"content":{"rendered":"\n<p>A builtin equivalent to the Unix\/Linux grep command is available in Windows, a bit less powerful though: findstr. You can do searches based on patterns, still in a measured way.<br>You don&#8217;t need to install anything, it is natively present on all Windows flavours.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Findstr Options<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">C:\\>findstr \/?\nSearches for strings in files.\n\nFINDSTR [\/B] [\/E] [\/L] [\/R] [\/S] [\/I] [\/X] [\/V] [\/N] [\/M] [\/O] [\/P] [\/F:file]\n[\/C:string] [\/G:file] [\/D:dir list] [\/A:color attributes] [\/OFF[LINE]]\nstrings [[drive:][path]filename[ ...]]<\/code><\/pre>\n\n\n\n<p><br>\/B Matches pattern if at the beginning of a line.<br>\/E Matches pattern if at the end of a line.<br>\/L Uses search strings literally.<br>\/R Uses search strings as regular expressions.<br>\/S Searches for matching files in the current directory and all<br>subdirectories.<br>\/I Specifies that the search is not to be case-sensitive.<br>\/X Prints lines that match exactly.<br>\/V Prints only lines that do not contain a match.<br>\/N Prints the line number before each line that matches.<br>\/M Prints only the filename if a file contains a match.<br>\/O Prints character offset before each matching line.<br>\/P Skip files with non-printable characters.<br>\/OFF[LINE] Do not skip files with offline attribute set.<br>\/A:attr Specifies color attribute with two hex digits. See &#8220;color \/?&#8221;<br>\/F:file Reads file list from the specified file(\/ stands for console).<br>\/C:string Uses specified string as a literal search string.<br>\/G:file Gets search strings from the specified file(\/ stands for console).<br>\/D:dir Search a semicolon delimited list of directories<br>strings Text to be searched for.<br>[drive:][path]filename<br>Specifies a file or files to search.<br><br>Use spaces to separate multiple search strings unless the argument is prefixed<br>with \/C. For example, &#8216;FINDSTR &#8220;hello there&#8221; x.y&#8217; searches for &#8220;hello&#8221; or<br>&#8220;there&#8221; in file x.y. &#8216;FINDSTR \/C:&#8221;hello there&#8221; x.y&#8217; searches for<br>&#8220;hello there&#8221; in file x.y.<br><br>Regular expression quick reference:<br>. Wildcard: any character<br>* Repeat: zero or more occurrences of previous character or class<br>^ Line position: beginning of line<br>$ Line position: end of line<br>[class] Character class: any one character in set<br>[^class] Inverse class: any one character not in set<br>[x-y] Range: any characters within the specified range<br>\\x Escape: literal use of metacharacter x<br>\\&lt;xyz Word position: beginning of word<br>xyz\\> Word position: end of word<br><br>For full information on FINDSTR regular expressions refer to the online Command<br><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/findstr\" target=\"_blank\" rel=\"noreferrer noopener\">Reference<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Command Usage Example<\/h2>\n\n\n\n<p>Pipe the previous command result to findstr, as you would with the grep command in Linux:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">C:\\>netstat -an | findstr 0.0.0.0\n  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING\n  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING\n  TCP    0.0.0.0:1033           0.0.0.0:0              LISTENING\n  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING\n  TCP    10.0.0.10:139          0.0.0.0:0              LISTENING\n  TCP    10.1.0.10:139          0.0.0.0:0              LISTENING\n  TCP    192.168.15.240:139     0.0.0.0:0              LISTENING\n  UDP    0.0.0.0:445            *:*\n  UDP    0.0.0.0:500            *:*\n  UDP    0.0.0.0:4500           *:*<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A builtin equivalent to the Unix\/Linux grep command is available in Windows, a bit less powerful though: findstr. You can do searches based on patterns, still in a measured way.You don&#8217;t need to install anything, it is natively present on all Windows flavours. Findstr Options \/B Matches pattern if at the beginning of a line.\/E [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[70],"tags":[266,267,391],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Findstr, a Native Alternative to grep in Windows<\/title>\n<meta name=\"description\" content=\"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Findstr, a Native Alternative to grep in Windows\" \/>\n<meta property=\"og:description\" content=\"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2009-09-27T19:51:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-01T11:55:36+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html\",\"url\":\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html\",\"name\":\"Netexpertise - Findstr, a Native Alternative to grep in Windows\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2009-09-27T19:51:07+00:00\",\"dateModified\":\"2021-06-01T11:55:36+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Findstr, a Native Alternative to grep in Windows\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Findstr, a Native Alternative to grep in Windows","description":"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Findstr, a Native Alternative to grep in Windows","og_description":"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.","og_url":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html","og_site_name":"Netexpertise","article_published_time":"2009-09-27T19:51:07+00:00","article_modified_time":"2021-06-01T11:55:36+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html","url":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html","name":"Netexpertise - Findstr, a Native Alternative to grep in Windows","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2009-09-27T19:51:07+00:00","dateModified":"2021-06-01T11:55:36+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"You would like to have grep on Windows natively? findstr is Windows grep equivalent and is present on all Windows systems.","breadcrumb":{"@id":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.netexpertise.eu\/en\/systems\/windows\/findstr-an-alternative-to-grep.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Findstr, a Native Alternative to grep in Windows"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/412"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}