Grep the whole body of a function
- by dotancohen
Supposing I know that someFile.php contains the definition for someFunction(). How would I go about displaying the whole body of the function in stdout? If I know that the body is 10 lines long then I would use cat someFile.php | grep -A 10 "function someFunction" [1] but in reality the function could be any arbitrary length.
I figured that with sed I could use Vimesque commands such as /function someFunction<Return>/{<Return>% [2] but I can't figure out exactly how to format it. Ideally, the PHPDoc before the function would be output along with the function.
Any help or links to the appropriate fine manual would be appreciated. Thanks!
[1] I know that the cat is redundant, but I find this format easier to read.
[2] Find the function definition, go to the opening brace, go to the close brace