{"id":1769,"date":"2019-11-27T22:46:19","date_gmt":"2019-11-27T22:46:19","guid":{"rendered":"http:\/\/linuxdigest.com\/?p=1769"},"modified":"2020-11-14T18:29:44","modified_gmt":"2020-11-14T18:29:44","slug":"grep-command-examples-you-must-know","status":"publish","type":"post","link":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/","title":{"rendered":"8 grep command examples you must know"},"content":{"rendered":"\n<p>If I had to rank Linux commands by how often I use them. I think grep would easily rank in the top 5-10. <\/p>\n\n\n\n<p>Grep simply takes a file or files and searches for a given pattern. It then prints out the line the pattern was found on.<\/p>\n\n\n\n<p>Grep can come in handy in so many situations. Need to find in which configuration file a certain parameter is? Need to find a particular IP address in your apache logs? Grep can solve those problems easily.<\/p>\n\n\n\n<p>I hope you find these grep examples useful.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"563\" height=\"205\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-001-cat-test-file.png\" alt=\"Test file for our grep example commands.\" class=\"wp-image-1772\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-001-cat-test-file.png 563w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-001-cat-test-file-300x109.png 300w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/figure><\/div>\n\n\n\n<p>Before we start we need a text file to search. I have created one that you can see in the attached image.<\/p>\n\n\n\n<p>We will use this file to text our grep command examples.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Simple grep example<\/h2>\n\n\n\n<p>The simplest grep example is just to search for a string of characters in a file: grep &lt;pattern&gt; &lt;file&gt;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep This test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"433\" height=\"56\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-003-simple.png\" alt=\"grep This test-file.txt\" class=\"wp-image-1775\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-003-simple.png 433w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-003-simple-300x39.png 300w\" sizes=\"(max-width: 433px) 100vw, 433px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Grep with regex<\/h2>\n\n\n\n<p>Finding complex patterns of text can be done using regular expressions. Let&#8217;s try finding any text that is between quote mark. If you are not familiar with regular expressions, there are tons of resources that can be found on Google. I like <a href=\"http:\/\/regextutorials.com\/\">Regex Tutorials<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E '\".*\"' test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"72\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-002-regex.png\" alt=\"grep -E '&quot;.*&quot;' test-file.txt\" class=\"wp-image-1770\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-002-regex.png 489w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-002-regex-300x44.png 300w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-002-regex-480x72.png 480w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/figure><\/div>\n\n\n\n<p>You can also shorten this command by using egrep. Egrep is basically the same as writing grep -E.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>egrep '\".*\"' test-file.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Grep all files in a directory<\/h2>\n\n\n\n<p>Looking through all files in a directory is simply a matter of replacing the filename with an asterisk (*). To make grep print the filename before each match use the -H option. If there are more than one files you can skip the -H option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -H This my-directory\/*<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"495\" height=\"56\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-004-asterisk.png\" alt=\"grep -H This my-directory\/*\" class=\"wp-image-1777\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-004-asterisk.png 495w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-004-asterisk-300x34.png 300w\" sizes=\"(max-width: 495px) 100vw, 495px\" \/><\/figure><\/div>\n\n\n\n<p>If you want to search all directories and subdirectories, you can use the -r option. This will instruct grep to recursively go through all directories and files in the path specified.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -r This my-directory\/*<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Grep in reverse<\/h2>\n\n\n\n<p>Want to have grep do the exact opposite of what it is supposed to do and print all the lines that don&#8217;t match and not the ones that match? No problem. Just use the -v option for invert match.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -v This test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"122\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-inverse.png\" alt=\"grep -v This test-file.txt\" class=\"wp-image-1779\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-inverse.png 482w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-inverse-300x76.png 300w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-inverse-480x122.png 480w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Print only the number of lines that match<\/h2>\n\n\n\n<p>If you only want to know how many lines contain your string you can use the -c option. Note that the -c option only counts the number of lines that match. Not how many times the pattern matches.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"66\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-count.png\" alt=\"grep -c grep test-file.txt\" class=\"wp-image-1780\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-count.png 460w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-005-count-300x43.png 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Case insensitive grep<\/h2>\n\n\n\n<p>Normally grep is case sensitive. Some times you want to grep for a pattern where it doesn&#8217;t matter if the characters are upper case or lower case. In that case you can use the -i option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -i ken test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"451\" height=\"60\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-006-case.png\" alt=\"grep -i ken test-file.txt\" class=\"wp-image-1782\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-006-case.png 451w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-006-case-300x40.png 300w\" sizes=\"(max-width: 451px) 100vw, 451px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Grep for multiple strings<\/h2>\n\n\n\n<p>If you have more than one pattern you need to grep for, -e specifies what pattern you want to use. You can use -e multiple times to use more than one pattern.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -e Ken -e file test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"70\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-multiple.png\" alt=\"grep -e Ken -e file test-file.txt\" class=\"wp-image-1783\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-multiple.png 531w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-multiple-300x40.png 300w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"> Grep lines before and after the match<\/h2>\n\n\n\n<p>This can be useful in cases where you are searching for a pattern in a log file but you want to know what came before or after the line you are matching. The -A, -B and -C options are what you need to know.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>-A 2<\/td><td>Print the next two lines after the matched line.<\/td><\/tr><tr><td>-B 2<\/td><td>Print the last two lines that came before the matched line.<\/td><\/tr><tr><td>-C 2<\/td><td>Print the last two lines that came before the matched line and also the next two after. Same as -A 2 -B 2.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>As an example, you can try printing one line before and one line after the match with -C 1.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -C 1 Wikipedia test-file.txt<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"529\" height=\"100\" src=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-C1.png\" alt=\"grep -C 1 Wikipedia test-file.txt\" class=\"wp-image-1784\" srcset=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-C1.png 529w, https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/1769-007-C1-300x57.png 300w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Using grep in bash scripts<\/h2>\n\n\n\n<p>Usually, the grep exit status is 0 if lines are found and 1 if none are found. If an error occurs, the exit status will be 2. If you don&#8217;t want the matched lines to be printed you would use grep&#8217;s -q option to suppress output.<\/p>\n\n\n\n<p>Here is a sample bash script that checks if a pattern exists.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if grep -q Globally test-file.txt\nthen\n  echo \"The string was found\"\nelse\n  echo \"The string was not found\"\nfi\n<\/code><\/pre>\n\n\n\n<p>Similarly, if you want to catch every possible exit status you could write a script like this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -q Globally test-file.txt\ngrepresult=$?\necho $grepresult\nif &#91;&#91; $grepresult -eq 0 ]]\nthen\n  echo \"The string was found\"\nelif &#91;&#91; $grepresult -eq 1 ]]\nthen\n  echo \"The string was not found\"\nelif &#91;&#91; $grepresult -eq 2 ]]\nthen\n  echo \"An error occured\"\nelse\n  echo \"Unknown exit code from grep\"\nfi\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Hopefully, you have found these grep examples helpful. In the Linux command line, the grep command is used quite frequently. So you learning these and other grep options can be of great help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If I had to rank Linux commands by how often I use them. I think grep&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1842,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27],"tags":[19,28,29],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>8 grep command examples you must know - Linux Digest<\/title>\n<meta name=\"description\" content=\"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"8 grep command examples you must know - Linux Digest\" \/>\n<meta property=\"og:description\" content=\"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Digest\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-27T22:46:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-14T18:29:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/Copy-of-Untitled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"The Linux Digest Guy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"The Linux Digest Guy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\"},\"author\":{\"name\":\"The Linux Digest Guy\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\"},\"headline\":\"8 grep command examples you must know\",\"datePublished\":\"2019-11-27T22:46:19+00:00\",\"dateModified\":\"2020-11-14T18:29:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\"},\"wordCount\":690,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"keywords\":[\"Command line\",\"grep\",\"search\"],\"articleSection\":[\"Command line tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\",\"url\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\",\"name\":\"8 grep command examples you must know - Linux Digest\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/#website\"},\"datePublished\":\"2019-11-27T22:46:19+00:00\",\"dateModified\":\"2020-11-14T18:29:44+00:00\",\"description\":\"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.\",\"breadcrumb\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/linuxdigest.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"8 grep command examples you must know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/linuxdigest.com\/#website\",\"url\":\"https:\/\/linuxdigest.com\/\",\"name\":\"Linux Digest\",\"description\":\"Linux tutorials for everyone\",\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/linuxdigest.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/linuxdigest.com\/#organization\",\"name\":\"Linux Digest\",\"url\":\"https:\/\/linuxdigest.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"contentUrl\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"width\":1102,\"height\":170,\"caption\":\"Linux Digest\"},\"image\":{\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\",\"name\":\"The Linux Digest Guy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"caption\":\"The Linux Digest Guy\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"8 grep command examples you must know - Linux Digest","description":"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.","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:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/","og_locale":"en_US","og_type":"article","og_title":"8 grep command examples you must know - Linux Digest","og_description":"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.","og_url":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/","og_site_name":"Linux Digest","article_published_time":"2019-11-27T22:46:19+00:00","article_modified_time":"2020-11-14T18:29:44+00:00","og_image":[{"width":300,"height":300,"url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/Copy-of-Untitled.png","type":"image\/png"}],"author":"The Linux Digest Guy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"The Linux Digest Guy","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#article","isPartOf":{"@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/"},"author":{"name":"The Linux Digest Guy","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2"},"headline":"8 grep command examples you must know","datePublished":"2019-11-27T22:46:19+00:00","dateModified":"2020-11-14T18:29:44+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/"},"wordCount":690,"commentCount":0,"publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"keywords":["Command line","grep","search"],"articleSection":["Command line tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/","url":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/","name":"8 grep command examples you must know - Linux Digest","isPartOf":{"@id":"https:\/\/linuxdigest.com\/#website"},"datePublished":"2019-11-27T22:46:19+00:00","dateModified":"2020-11-14T18:29:44+00:00","description":"Here are some grep command examples to get you started. Simple grep example. Grep with regex. Grep in reverse. Grep for multiple strings.","breadcrumb":{"@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/linuxdigest.com\/howto\/grep-command-examples-you-must-know\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxdigest.com\/"},{"@type":"ListItem","position":2,"name":"8 grep command examples you must know"}]},{"@type":"WebSite","@id":"https:\/\/linuxdigest.com\/#website","url":"https:\/\/linuxdigest.com\/","name":"Linux Digest","description":"Linux tutorials for everyone","publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxdigest.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxdigest.com\/#organization","name":"Linux Digest","url":"https:\/\/linuxdigest.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","contentUrl":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","width":1102,"height":170,"caption":"Linux Digest"},"image":{"@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2","name":"The Linux Digest Guy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","caption":"The Linux Digest Guy"}}]}},"_links":{"self":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1769"}],"collection":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/comments?post=1769"}],"version-history":[{"count":8,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1769\/revisions"}],"predecessor-version":[{"id":1877,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1769\/revisions\/1877"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media\/1842"}],"wp:attachment":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media?parent=1769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/categories?post=1769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/tags?post=1769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}