How to grep through insanely nested folders to find a string
Agaric forever owes a huge debt of gratitude (and a drink or something) to jmorahan, IRC hero.
I think I have a menu_rebuild that's being called way too often. What is the unix command for looking through everything in a whole nested directory, from Drupal root on down? grep something something menu_rebuild something something?
(please don't tell me to 'man grep' -- that's what I did and why what little I knew about how to use it has been lost, as evidenced by this query)jmorahan
grep -nHR menu_rebuild /path/to/drupal/rootben-agaric
WOW! jmorahan, thank you!
(and there are way too many modules that use menu_rebuild ;-)
Note that we should have been able to figure out that command from man grep. We'll analyze what n, H, and R are later.
This is superior to other solutions on Agaric's site because it doesn't care what level the files it looks through are on, it doesn't care how deeply nested things are. On the other hand it doesn't exclude SVN, but it's awesome, and even possible to remember:
grep -nHR sought_string /path/to/root/directory
Update: As of 2008 August, Druplicon in irc.freenode.net's #drupal has it's own take on grep:
grep -R -B2 -A3 "string to find" /folder/to/search/recursively/* (where -Bn and -An are how many lines to display -Before and -After)
Resolution
More like this
- Grep (search) through files in multiple folders avoiding .svn directories
- Making changes to a nested array that may have arrays or strings in some values
- Find a term ID (working around the category module) to have a node behave differently
- Nesting nodes, nodes connected to sections depending where in the site they are created
- Translation of User Interface strings in DrupaAdministration


Comments
Post new comment