{"id":22677,"date":"2017-06-28T03:39:46","date_gmt":"2017-06-28T08:39:46","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=22677"},"modified":"2022-12-16T06:20:03","modified_gmt":"2022-12-16T12:20:03","slug":"linux-grep-command-examples","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/","title":{"rendered":"Linux Grep Command Examples"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><figure id=\"attachment_28797\" aria-describedby=\"caption-attachment-28797\" style=\"width: 732px\" class=\"wp-caption alignnone\"><img decoding=\"async\" class=\"size-full wp-image-28797\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg\" alt=\"Linux Grep Command Examples.\" width=\"742\" height=\"371\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg 742w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples-150x75.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples-300x150.jpg 300w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><figcaption id=\"caption-attachment-28797\" class=\"wp-caption-text\">Linux Grep Command Examples.<\/figcaption><\/figure>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-28795\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/grep-command-in-linux-with-examples.jpg\" alt=\"grep command in linux with examples\" width=\"120\" height=\"145\" \/>In this article, we are going to provide you with useful <strong>examples of the Linux grep command<\/strong>, including the two variant programs: egrep and fgrep. <b>grep <\/b>(global regular expression print) is used to search for text strings and regular expressions line by line which matches a specified pattern within one or more files.<\/p>\n<p>Listed below are some simple and useful examples of <span class=\"st\"><strong>how to use the grep command on Linux<\/strong> and search for a string in one\/multiple files.<\/span><br \/>\n<!--more--><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69df79897c530\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69df79897c530\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#1-Grep-Command-Example-on-how-to-search-for-lines-in-a-specific-file\" >1. Grep Command Example on how to search for lines in a specific file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#2-Grep-Command-Example-on-how-to-search-for-specific-text-in-all-files\" >2. Grep Command Example on how to search for specific text in all files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#4-Grep-Command-Example-on-how-to-add-line-numbers-to-search-results\" >4. Grep Command Example on how to add\u00a0line numbers to search results<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#5-Grep-Command-Example-on-how-to-search-in-all-files-for-specific-text-recursively\" >5. Grep Command Example on how to search in all files for specific text\u00a0recursively<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#6-Grep-Command-Example-on-how-to-search-for-lines-in-the-current-directory\" >6. Grep Command Example on how to search for lines in the current directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#6-Grep-Command-Example-on-how-to-list-all-Apache-processes\" >6. Grep Command Example on how to list all Apache processes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#7-Grep-Command-Example-on-how-to-see-which-socket-belongs-to-process-ID\" >7. Grep Command Example on how to see which socket belongs to process ID<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#7-Grep-Command-Example-on-how-to-display-the-total-number-of-connections-on-a-specific-port\" >7. Grep Command Example on how to display the total number of connections on a specific port<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#8-Grep-Command-Example-on-how-to-remove-all-frozen-messages-in-Exim-mail-queue\" >8. Grep Command Example on how to remove all frozen messages in Exim mail queue<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#9-Grep-Command-Example-on-how-to-find-a-file-with-text-pattern\" >9. Grep Command Example on how to find a file with text pattern<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"1-Grep-Command-Example-on-how-to-search-for-lines-in-a-specific-file\"><\/span>1. Grep Command Example on how to search for lines in a specific file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-28798\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Grep-Command-in-Linux-Examples..jpg\" alt=\"Grep Command in Linux Examples\" width=\"120\" height=\"120\" \/>Search for lines containing &#8216;DB_USER&#8217; in WordPress configuration file (wp-config.php):<\/p>\n<pre># grep 'DB_USER' wp-config.php\r\ndefine('DB_USER', 'wpuser');<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"2-Grep-Command-Example-on-how-to-search-for-specific-text-in-all-files\"><\/span>2. Grep Command Example on how to search for specific text in all files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Search for all PHP files containing &#8216;str_replace&#8217; text inside the &#8216;wp-admin&#8217; directory of a WordPress installation:<\/p>\n<pre># # grep \"str_replace\" admin*.php\r\nadmin-ajax.php: add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );\r\nadmin-ajax.php: add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );\r\nadmin-header.php:$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );\r\nadmin-header.php:$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '\/^([.0-9]+).*\/', '$1', $wp_version ) );\r\nadmin-header.php:$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"4-Grep-Command-Example-on-how-to-add-line-numbers-to-search-results\"><\/span>4. Grep Command Example on how to add\u00a0line numbers to search results<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you want to add line numbers to search results, use the following command:<\/p>\n<pre># grep -n \"str_replace\" admin*.php\r\nadmin-ajax.php:73:      add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );\r\nadmin-ajax.php:76:      add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );\r\nadmin-header.php:157:$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );\r\nadmin-header.php:158:$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '\/^([.0-9]+).*\/', '$1', $wp_version ) );\r\nadmin-header.php:160:$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"5-Grep-Command-Example-on-how-to-search-in-all-files-for-specific-text-recursively\"><\/span>5. Grep Command Example on how to search in all files for specific text\u00a0recursively<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Search for all PHP files whose contents mention &#8216;str_replace&#8217; text which has either capital or small letters in it, located in the &#8216;wp-admin&#8217; directory recursively (i.e. read all files under each directory) and lists<img decoding=\"async\" class=\"alignright size-full wp-image-28803\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-grep-command-and-Examples.jpg\" alt=\"Linux grep command and Examples\" width=\"120\" height=\"153\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-grep-command-and-Examples.jpg 120w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-grep-command-and-Examples-118x150.jpg 118w\" sizes=\"(max-width: 120px) 100vw, 120px\" \/> the file names only:<\/p>\n<pre># grep -ril \"str_replace\" admin*.php\r\nadmin-ajax.php\r\nadmin-header.php<\/pre>\n<p>grep command is often used in a Unix\/Linux pipeline with other commands. Listed below are some more advanced examples of <span class=\"st\">how to use the grep command on Linux:<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"6-Grep-Command-Example-on-how-to-search-for-lines-in-the-current-directory\"><\/span>6. Grep Command Example on how to search for lines in the current directory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-28799\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/how-to-use-grep-command.jpg\" alt=\"how to use grep command\" width=\"109\" height=\"150\" \/>Search for lines containing &#8216;eval&#8217; in all PHP files located in the current directory:<\/p>\n<pre>#find . -name '*.php' -exec grep -l 'eval' {} \\;\r\n.\/wp-admin\/includes\/image.php\r\n.\/wp-admin\/includes\/class-wp-upgrader.php\r\n.\/wp-admin\/includes\/class-pclzip.php\r\n.\/wp-admin\/includes\/media.php\r\n.\/wp-admin\/includes\/update-core.php\r\n.\/wp-admin\/includes\/ajax-actions.php\r\n.\/wp-admin\/includes\/class-wp-automatic-updater.php\r\n.\/wp-admin\/includes\/class-wp-posts-list-table.php\r\n.\/wp-admin\/user-edit.php\r\n.\/wp-admin\/edit-tag-form.php<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"6-Grep-Command-Example-on-how-to-list-all-Apache-processes\"><\/span>6. Grep Command Example on how to list all Apache processes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>List all Apache processes:<\/p>\n<pre># ps aux | grep http\r\nroot      1259  0.0  0.0 114644   984 pts\/0    S+   01:37   0:00 grep --color=auto http\r\nroot      1471  0.0  2.3 502008 24508 ?        Ss   Jun27   0:03 \/usr\/sbin\/httpd -k start\r\nnobody   31256  0.0  3.8 510140 40412 ?        S    00:00   0:01 \/usr\/sbin\/httpd -k start\r\nnobody   31257  0.0  4.2 510220 44404 ?        S    00:00   0:02 \/usr\/sbin\/httpd -k start\r\nnobody   31258  0.0  4.5 511156 47924 ?        S    00:00   0:02 \/usr\/sbin\/httpd -k start\r\nnobody   31259  0.0  5.4 514240 56648 ?        S    00:00   0:02 \/usr\/sbin\/httpd -k start\r\nnobody   31260  0.0  3.9 510388 41668 ?        S    00:00   0:01 \/usr\/sbin\/httpd -k start\r\nnobody   31585  0.0  4.2 511156 44188 ?        S    00:13   0:01 \/usr\/sbin\/httpd -k start<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7-Grep-Command-Example-on-how-to-see-which-socket-belongs-to-process-ID\"><\/span>7. Grep Command Example on how to see which socket belongs to process ID<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>See which sockets belong to process ID 31585:<\/p>\n<pre># lsof -p 31585 | grep -Ei 'cwd|unix|sock'\r\nhttpd   31585 nobody  cwd    DIR    144,142     4096   35120509 \/\r\nhttpd   31585 nobody  mem    REG       8,18            38427466 \/opt\/cpanel\/ea-php56\/root\/usr\/lib64\/php\/modules\/sockets.so (path dev=144,142)\r\nhttpd   31585 nobody  mem    REG       8,18            36064050 \/usr\/lib64\/apache2\/modules\/mod_unixd.so (path dev=144,142)<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7-Grep-Command-Example-on-how-to-display-the-total-number-of-connections-on-a-specific-port\"><\/span>7. Grep Command Example on how to display the total number of connections on a specific port<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img decoding=\"async\" class=\"alignright size-full wp-image-28802\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/grep-command.jpg\" alt=\"grep command\" width=\"120\" height=\"74\" \/>Display total number of Apache connections on port 80:<\/p>\n<pre># netstat -an | grep :80 |wc -l\r\n1627<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"8-Grep-Command-Example-on-how-to-remove-all-frozen-messages-in-Exim-mail-queue\"><\/span>8. Grep Command Example on how to remove all frozen messages in Exim mail queue<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Remove all frozen messages in Exim mail queue immediately:<\/p>\n<pre>#exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm\r\nMessage 1dPhFh-0000t6-D0 has been removed\r\nMessage 1dPenR-0000Ls-S8 has been removed\r\nMessage 1dPexx-0000OD-A6 has been removed<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"9-Grep-Command-Example-on-how-to-find-a-file-with-text-pattern\"><\/span>9. Grep Command Example on how to find a file with text pattern<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Find files containing a text pattern (e.g. hello):<\/p>\n<pre>find . -iname \"*.txt\" -exec grep -l \"hello\" {} +<\/pre>\n<p>To search for multiple patterns at one time, you can simply use the egrep command. egrep is the same as grep -E.<\/p>\n<pre>#egrep 'cachedir|exclude' \/etc\/yum.conf\r\ncachedir=\/var\/cache\/yum\/$basearch\/$releasever\r\nexclude=lm_sensors*<\/pre>\n<p>The fgrep searches a file or list of files for a fixed pattern string. fgrep is the same as grep \u2013F.<\/p>\n<pre>#fgrep 'cachedir' \/etc\/yum.conf\r\ncachedir=\/var\/cache\/yum\/$basearch\/$releasever\r\n\r\n<\/pre>\n<p><!--more--><\/p>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-28800\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/using-grep-command-in-Linux.jpg\" alt=\"using grep command in Linux\" width=\"200\" height=\"219\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/using-grep-command-in-Linux.jpg 200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/using-grep-command-in-Linux-137x150.jpg 137w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/>Of course, you don\u2019t have to learn the <strong>grep commands in Linux<\/strong>, if you use one of our <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting.html\">managed &amp; optimized VPS Hosting services<\/a>, in which case you can simply ask our expert Linux admins to help you with grep command on your Linux server. They are available 24&#215;7 and will take care of your request immediately. You can also read our post about <a href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-guide-for-advanced-users\/\">Linux Grep Guide for Advanced Users<\/a>.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>PS<\/strong><\/span>. If you liked this post about <strong>Linux grep Command Examples<\/strong>, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to provide you with useful examples of the Linux grep command, including the two &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Linux Grep Command Examples\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#more-22677\" aria-label=\"Read more about Linux Grep Command Examples\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":28797,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[103,1571,1573,118,1572],"class_list":["post-22677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips-and-tricks","tag-commands","tag-egrep","tag-fgrep","tag-grep","tag-pgrep","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Linux Grep Command Examples<\/title>\n<meta name=\"description\" content=\"We are going to provide you with useful examples of Linux grep command including the two variant programs: egrep and fgrep. 12 usefull Linux Grep Commands.\" \/>\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.rosehosting.com\/blog\/linux-grep-command-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux Grep Command Examples\" \/>\n<meta property=\"og:description\" content=\"Linux Grep Command Examples | RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-28T08:39:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-16T12:20:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"371\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"Linux Grep Command Examples\",\"datePublished\":\"2017-06-28T08:39:46+00:00\",\"dateModified\":\"2022-12-16T12:20:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/\"},\"wordCount\":535,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Linux-Grep-Command-Examples.jpg\",\"keywords\":[\"Commands\",\"egrep\",\"fgrep\",\"grep\",\"pgrep\"],\"articleSection\":[\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/\",\"name\":\"Linux Grep Command Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Linux-Grep-Command-Examples.jpg\",\"datePublished\":\"2017-06-28T08:39:46+00:00\",\"dateModified\":\"2022-12-16T12:20:03+00:00\",\"description\":\"We are going to provide you with useful examples of Linux grep command including the two variant programs: egrep and fgrep. 12 usefull Linux Grep Commands.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Linux-Grep-Command-Examples.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Linux-Grep-Command-Examples.jpg\",\"width\":742,\"height\":371,\"caption\":\"Linux Grep Command Examples.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/linux-grep-command-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux Grep Command Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Linux Grep Command Examples","description":"We are going to provide you with useful examples of Linux grep command including the two variant programs: egrep and fgrep. 12 usefull Linux Grep Commands.","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.rosehosting.com\/blog\/linux-grep-command-examples\/","og_locale":"en_US","og_type":"article","og_title":"Linux Grep Command Examples","og_description":"Linux Grep Command Examples | RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2017-06-28T08:39:46+00:00","article_modified_time":"2022-12-16T12:20:03+00:00","og_image":[{"width":742,"height":371,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"Linux Grep Command Examples","datePublished":"2017-06-28T08:39:46+00:00","dateModified":"2022-12-16T12:20:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/"},"wordCount":535,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg","keywords":["Commands","egrep","fgrep","grep","pgrep"],"articleSection":["Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/","url":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/","name":"Linux Grep Command Examples","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg","datePublished":"2017-06-28T08:39:46+00:00","dateModified":"2022-12-16T12:20:03+00:00","description":"We are going to provide you with useful examples of Linux grep command including the two variant programs: egrep and fgrep. 12 usefull Linux Grep Commands.","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/06\/Linux-Grep-Command-Examples.jpg","width":742,"height":371,"caption":"Linux Grep Command Examples."},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/linux-grep-command-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Linux Grep Command Examples"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=22677"}],"version-history":[{"count":3,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22677\/revisions"}],"predecessor-version":[{"id":44385,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22677\/revisions\/44385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/28797"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=22677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=22677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=22677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}