{"id":19629,"date":"2020-07-16T16:18:18","date_gmt":"2020-07-16T23:18:18","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19629"},"modified":"2023-12-01T03:55:23","modified_gmt":"2023-12-01T11:55:23","slug":"linux-grep-command","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/","title":{"rendered":"How to Use the Linux Grep Command"},"content":{"rendered":"\n<p>Have you ever thought that the search features offered by text editors are rather simple? It\u2019s not just you. It can be quite difficult to search through files, especially if you want to search for text that matches a pattern.<br><\/p>\n\n\n\n<p>That\u2019s where the grep command comes in handy. The grep command allows you to perform advanced searches on a text file.<br><\/p>\n\n\n\n<p>In this guide, we\u2019re going to talk about what the grep command on Linux is and how it works. We\u2019ll walk through a few examples to help you get started using the Linux grep command. Let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the Grep Command?<\/h2>\n\n\n\n<p>Grep stands for Global Search for Regular Expression and Print Out. It allows you to search a particular file using patterns called regular expressions.<br><\/p>\n\n\n\n<p>Grep can be used on any file to check for pattern matches using global regular expression. It is often used to search for a string in a log file from a Linux and Unix command line.<br><\/p>\n\n\n\n<p>The most simple usage of the grep command is looking for a line of text in a file. In this tutorial, we\u2019re going to be working with a file called muffin_recipe.txt. This file contains a list of ingredients needed to make a muffin:<br><\/p>\n\n\n\n<p>2 medium eggs<\/p>\n\n\n\n<p>125ml vegetable oil<\/p>\n\n\n\n<p>250ml semi-skimmed milk<\/p>\n\n\n\n<p>250g golden caster sugar<\/p>\n\n\n\n<p>400g self raising flour<br><\/p>\n\n\n\n<p>Let\u2019s say that we want to search for whether this file contains <code>eggs<\/code>. We could do this using the grep command:<br><\/p>\n\n\n\n<p><code>grep \u201ceggs\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>You need to surround your search query in either single or double quotes if it is more than one word. We have opted to do it anyway in this example because it is good practice. Our command returns:<br><\/p>\n\n\n\n<p>2 medium eggs<br><\/p>\n\n\n\n<p>By default, the grep command returns a list of all the lines in a file which match a particular query. Grep will match our query with the input file and return all the text on a line that meets that query. Above, you can see that \u201c2 medium eggs\u201d was returned, rather than just \u201ceggs\u201d, which was our original search query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using Grep to Filter a Command Output<\/h2>\n\n\n\n<p>The grep command is commonly used to filter the output of a command. This is because you can use redirection with grep; you don\u2019t need to specify a file through which grep should search.<br><\/p>\n\n\n\n<p>Consider the following example:<br><\/p>\n\n\n\n<p><code>ls | grep \u201cDo\u201d<br><\/code><\/p>\n\n\n\n<p>This command will return a list of all the files and folders that start with \u201cDo\u201d in our current working directory. We use \u201cls\u201d to list all the files in our folder and then we use grep to filter out the files and folders that begin with \u201cDo\u201d:<br><\/p>\n\n\n\n<p>Desktop<\/p>\n\n\n\n<p>Documents<\/p>\n\n\n\n<p>Downloads<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Perform a Recursive Search<\/h2>\n\n\n\n<p>What makes grep really powerful is that it doesn\u2019t have to be run on one file. Grep can search multiple files for a particular query. Consider the following command:<br><\/p>\n\n\n\n<p><code>grep -r \u201cegg\u201d recipes\/<br><\/code><\/p>\n\n\n\n<p>This command will search for the term \u201cegg\u201d in a folder called recipes. This command returns a list of all the files that include \u201cegg\u201d as well as all the text that appears on the line that matches this term:<br><\/p>\n\n\n\n<p><code>\/Users\/James\/recipes\/scone_recipe.txt: 1 medium egg<\/code><\/p>\n\n\n\n<p><code>\/Users\/James\/recipes\/muffin_recipe.txt: 2 medium eggs<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to List Line Numbers<\/h2>\n\n\n\n<p>You may want to find out what line of text a particular phrase appears on. You can do this using the -n option, which displays line numbers alongside the result of a grep:<br><\/p>\n\n\n\n<p><code>grep -n \u201cml\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This command returns:<br><\/p>\n\n\n\n<p>2:125ml vegetable oil<\/p>\n\n\n\n<p>3:250ml semi-skimmed milk<br><\/p>\n\n\n\n<p>Our file contains two lines with the text <code>ml<\/code>. These phrases appear on lines 2 and 3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Exclude a Term<\/h2>\n\n\n\n<p>The grep command allows you to display text that does not match a pattern. Let\u2019s retrieve a list of all the ingredients which are not liquid. To do this, we will assume that liquid ingredients are measured in mls:<br><\/p>\n\n\n\n<p><code>grep -v \u201cml\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This command returns:<br><\/p>\n\n\n\n<p>2 medium eggs<\/p>\n\n\n\n<p>250g golden caster sugar<\/p>\n\n\n\n<p>400g self raising flour<br><\/p>\n\n\n\n<p>We now have a list of all the ingredients which do not contain \u201cml\u201d.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Ignore Cases<\/h2>\n\n\n\n<p>The grep command is case sensitive by default. This means that if you search for a term, it will only return terms which match that case. You can use the -i option to ignore cases.<br><\/p>\n\n\n\n<p>Let\u2019s search for the term \u201cEGG\u201d in our file <code>muffin_recipe.txt<\/code>:<br><\/p>\n\n\n\n<p><code>grep -i \u201cEGG\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This command returns: 2 medium eggs. If we did not specify the -i flag, this command would return nothing. This is because only \u201cegg\u201d appears in the file, and \u201cEGG\u201d is treated differently to \u201cegg\u201d.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Show Only Filenames<\/h2>\n\n\n\n<p>The grep command, by default, shows all the lines of text in a file which matches a particular pattern. You can override this and instruct grep to only show the names of the files containing a pattern using the -l flag. Consider this command:<br><\/p>\n\n\n\n<p><code>grep -l \u201cegg\u201d recipes\/*.txt<br><\/code><\/p>\n\n\n\n<p>This will search for the term \u201cegg\u201d in all files that end in .txt in the recipes\/ folder:<br><\/p>\n\n\n\n<p><code>muffin_recipe.txt<\/code><\/p>\n\n\n\n<p><code>scone_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This tells us that eggs are used in two recipes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Search for a Whole Word<\/h2>\n\n\n\n<p>The grep command displays all the lines of text in a file where the string is contained within a larger string. For instance, if we tried to search for \u201c5ml\u201d, it would return all ingredients with a liquid quantity ending with \u201c5ml\u201d, such as \u201c55ml\u201d, \u201c95ml\u201d, and \u201c5ml\u201d.<br><\/p>\n\n\n\n<p>You can use the -w flag to search for a whole word:<br><\/p>\n\n\n\n<p><code>grep -w \u201c5ml\u201d recipes\/*.txt<br><\/code><\/p>\n\n\n\n<p>This command searches for the term \u201c5ml\u201d inside our recipes folder.<br><\/p>\n\n\n\n<p><code>recipes\/scone_recipe.txt:5ml vanilla extract<br><\/code><\/p>\n\n\n\n<p>We are only shown the lines that explicitly include the word \u201c5ml\u201d.<br><\/p>\n\n\n\n<p>How to Count Matches<br><\/p>\n\n\n\n<p>Let\u2019s find out how many wet ingredients we use in our muffin recipe. We\u2019ll assume that dry ingredients are measured in milliliters (ml). To count the number of lines that match a particular query, you can use the -c option:<br><\/p>\n\n\n\n<p><code>grep -c \u201cml\u201d scone_recipe.txt<br><\/code><\/p>\n\n\n\n<p>Our code returns: 2. Our file contains 2 instances of the \u201cml\u201d pattern.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Print Lines After a Search<\/h2>\n\n\n\n<p>You can print out the lines of text in a file that appear before or after the result of a search.<br><\/p>\n\n\n\n<p>The -A flag allows you to print the lines after a match, including the match; the -B flag prints the lines of text before a match, including the match. Let\u2019s print out the line \u201c2 medium eggs\u201d and the two lines in our <code>muffin_recipe.txt<\/code> file:<br><\/p>\n\n\n\n<p><code>grep -A 2 \u201c2 medium eggs\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>Our command returns:<br><\/p>\n\n\n\n<p>2 medium eggs<\/p>\n\n\n\n<p>125ml vegetable oil<\/p>\n\n\n\n<p>250ml semi-skimmed milk<br><\/p>\n\n\n\n<p>We can print out the 2 lines which come before \u201c400g self raising flour\u201d using this command:<br><\/p>\n\n\n\n<p><code>grep -B 2 \u201c400g self raising flour\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This command returns the matched line and the two lines which appear before it:<br><\/p>\n\n\n\n<p>250ml semi-skimmed milk<\/p>\n\n\n\n<p>250g golden caster sugar<\/p>\n\n\n\n<p>400g self-raising flour<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use Regular Expressions<\/h2>\n\n\n\n<p>It\u2019s not surprising that grep supports regular expressions: the clue is in the name. By default, grep reads any term you specify as a basic regular expression. This means that we can conduct advanced pattern-based searches using basic regular expressions.<br><\/p>\n\n\n\n<p>Let\u2019s walk through two regular expression patterns:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>^: Search at the beginning of a line.<\/li><li>$: Search at the end of a line.<\/li><\/ul>\n\n\n\n<p>We\u2019ll start by searching for any ingredients that begin with \u201c250\u201d in <code>muffin_recipe.txt<\/code>:<br><\/p>\n\n\n\n<p><code>grep \u201c^250\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>Two matches are found:<br><\/p>\n\n\n\n<p>250ml semi-skimmed milk<\/p>\n\n\n\n<p>250g golden caster sugar<br><\/p>\n\n\n\n<p>You can see that our search has found any ingredients starting with \u201c250&#8243;, irrespective of the units in which those ingredients are measured. Now, let\u2019s generate a list of all the ingredients that end in \u201csugar\u201d in muffin_recipe.txt:<br><\/p>\n\n\n\n<p><code>grep \u201csugar$\u201d muffin_recipe.txt<br><\/code><\/p>\n\n\n\n<p>This searches for any lines which end in \u201csugar\u201d. Our command returns: 250g golden caster sugar. Only one line of text ends in \u201csugar\u201d, and that is the one that is printed to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The grep command allows you to search through files using the Linux operating system. It can be used to search through an individual file or through multiple files.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to start using the grep command like a Linux expert!<br><\/p>\n","protected":false},"excerpt":{"rendered":"Have you ever thought that the search features offered by text editors are rather simple? It\u2019s not just you. It can be quite difficult to search through files, especially if you want to search for text that matches a pattern. That\u2019s where the grep command comes in handy. The grep command allows you to perform&hellip;","protected":false},"author":240,"featured_media":19630,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[18070],"tags":[],"class_list":{"0":"post-19629","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-software-engineering-skills"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"how to use {tool}","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use the Linux Grep Command | Career Karma<\/title>\n<meta name=\"description\" content=\"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use the Linux Grep Command\" \/>\n<meta property=\"og:description\" content=\"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-16T23:18:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:55:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"602\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use the Linux Grep Command\",\"datePublished\":\"2020-07-16T23:18:18+00:00\",\"dateModified\":\"2023-12-01T11:55:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\"},\"wordCount\":1303,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg\",\"articleSection\":[\"Software Engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\",\"name\":\"How to Use the Linux Grep Command | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg\",\"datePublished\":\"2020-07-16T23:18:18+00:00\",\"dateModified\":\"2023-12-01T11:55:23+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg\",\"width\":1000,\"height\":602},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coding\",\"item\":\"https:\/\/careerkarma.com\/blog\/code\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Use the Linux Grep Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Use the Linux Grep Command | Career Karma","description":"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.","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:\/\/careerkarma.com\/blog\/linux-grep-command\/","og_locale":"en_US","og_type":"article","og_title":"How to Use the Linux Grep Command","og_description":"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.","og_url":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-16T23:18:18+00:00","article_modified_time":"2023-12-01T11:55:23+00:00","og_image":[{"width":1000,"height":602,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use the Linux Grep Command","datePublished":"2020-07-16T23:18:18+00:00","dateModified":"2023-12-01T11:55:23+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/"},"wordCount":1303,"commentCount":1,"image":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg","articleSection":["Software Engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/linux-grep-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/","url":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/","name":"How to Use the Linux Grep Command | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg","datePublished":"2020-07-16T23:18:18+00:00","dateModified":"2023-12-01T11:55:23+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The grep command allows you to search through text files in Linux. On Career Karma, learn how to use the Linux grep command.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/linux-grep-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/florian-krumm-1osIUArK5oA-unsplash.jpg","width":1000,"height":602},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/linux-grep-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Coding","item":"https:\/\/careerkarma.com\/blog\/code\/"},{"@type":"ListItem","position":3,"name":"How to Use the Linux Grep Command"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19629"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19629\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19630"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}