{"id":9198,"date":"2026-06-01T02:53:07","date_gmt":"2026-06-01T00:53:07","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9198"},"modified":"2026-06-01T02:53:09","modified_gmt":"2026-06-01T00:53:09","slug":"cum-sa-cautati-folosind-comanda-grep","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/","title":{"rendered":"Cum s\u0103 c\u0103uta\u021bi folosind comanda GREP?"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\"><code>grep<\/code> is one of the most commonly used Linux and Unix command-line tools for searching text. It allows you to find specific words, phrases, or patterns within files and command output.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The command is especially useful when analyzing logs, configuration files, or large amounts of text data.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<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:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Basic_syntax\" >Basic syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Example\" >Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Searching_multiple_files\" >Searching multiple files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Case-insensitive_search\" >Case-insensitive search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Recursive_directory_search\" >Recursive directory search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Using_GREP_with_other_commands\" >Using GREP with other commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Common_use_cases\" >Common use cases<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-search-using-the-grep-command\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Basic_syntax\"><\/span>Basic syntax<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-2978737708\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">To search for a specific string inside a file, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep 'search_string' filename\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>search_string<\/code> is the text you want to find<\/li>\n\n\n\n<li><code>filename<\/code> is the file being searched<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The command will display all lines containing the specified text.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example\"><\/span>Example<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To search for the word <code>error<\/code> in a log file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep 'error' error.log\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The output will show every line in the file that contains the word <code>error<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Searching_multiple_files\"><\/span>Searching multiple files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can search through multiple files at the same time:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep 'error' *.log\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command searches all <code>.log<\/code> files in the current directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Case-insensitive_search\"><\/span>Case-insensitive search<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To ignore uppercase and lowercase differences, use the <code>-i<\/code> option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -i 'error' error.log\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will match:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>error<\/li>\n\n\n\n<li>Error<\/li>\n\n\n\n<li>ERROR<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">and other letter-case variations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Recursive_directory_search\"><\/span>Recursive directory search<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To search all files within a directory and its subdirectories, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -r 'error' \/path\/to\/directory\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is particularly useful when troubleshooting applications or websites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_GREP_with_other_commands\"><\/span>Using GREP with other commands<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>grep<\/code> can also filter the output of other commands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps aux | grep apache\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays running processes containing the word <code>apache<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Common_use_cases\"><\/span>Common use cases<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GREP is often used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>search server logs<\/li>\n\n\n\n<li>find configuration settings<\/li>\n\n\n\n<li>filter command output<\/li>\n\n\n\n<li>locate specific errors<\/li>\n\n\n\n<li>analyze application data<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>grep<\/code> command is a powerful text-searching tool that helps locate specific words, phrases, or patterns in files and command output. It is widely used for log analysis, troubleshooting, and system administration tasks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[54],"manual_kb_tag":[1097,1519,5830,5831,5832,5833,5834,5835,5836,5837],"class_list":["post-9198","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-ssh","manual_kb_tag-log-analysis","manual_kb_tag-grep","manual_kb_tag-grep-command","manual_kb_tag-linux-grep","manual_kb_tag-unix-grep","manual_kb_tag-text-search","manual_kb_tag-search-text","manual_kb_tag-analyze-logs","manual_kb_tag-search-logs","manual_kb_tag-recursive-search"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9198\/revisions"}],"predecessor-version":[{"id":9199,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9198\/revisions\/9199"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=9198"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9198"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=9198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}