{"id":456,"date":"2015-08-13T08:27:11","date_gmt":"2015-08-13T02:57:11","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=456"},"modified":"2015-08-13T08:27:11","modified_gmt":"2015-08-13T02:57:11","slug":"searching-for-file-containing-keyword-in-linux","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=456","title":{"rendered":"Searching for file containing keyword in Linux"},"content":{"rendered":"<p>Grep suits the bill for all my requirement for efficient search of files containing text in Linux and Mac. The following commands detail the use cases of grep.<\/p>\n<p><strong>Search for pattern<\/strong><br \/>\n<code>grep -rnw 'folder' -e 'text'<\/code><\/p>\n<p>-r stands for recursive.<br \/>\n-n is the line number.<br \/>\n-w stands for whole word match.<\/p>\n<p>Example: <code>grep -rnw . -e 'import'<\/code><br \/>\nThis searches for the the text &#8216;import&#8217; in the current directory recursively. <\/p>\n<p>Found this tip at <a href=\"http:\/\/stackoverflow.com\/questions\/16956810\/finding-all-files-containing-a-text-string-on-linux\">stackoverflow.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grep suits the bill for all my requirement for efficient search of files containing text in Linux and Mac. The following commands detail the use cases of grep. Search for pattern grep -rnw &#8216;folder&#8217; -e &#8216;text&#8217; -r stands for recursive. -n is the line number. -w stands for whole word match. Example: grep -rnw . [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,35,24],"tags":[],"class_list":["post-456","post","type-post","status-publish","format-standard","hentry","category-linux-os","category-mac-os","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=456"}],"version-history":[{"count":3,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/456\/revisions"}],"predecessor-version":[{"id":459,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/456\/revisions\/459"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}