Lets say I have a java class called DirectAction
some of the methods in the class have the word "action" or "Action"
What is the grep command to get the names of all the methods who have "Action" or "action" and write it to an external file?
Example:
public class DirectAction extends ERXDirectAction { /** * * @param aRequest */ public DirectAction(WORequest aRequest) { } // ============================================================================================ // ACTIONS /** * Default Action * */ @docDirectAction public WOActionResults defaultAction() { } /** * @return goes to login page for student */ @docDirectAction public WOActionResults studentAction() { ); return nextPage; } /** * @return goes to Admin login page */ @docDirectAction public WOActionResults adminAction() { return nextPage; } /** * @return calls the AdminAction */ @docDirectAction public WOActionResults staffAction() { return adminAction(); }
}
I want to get only the below output.
public class DirectAction extends ERXDirectAction public DirectAction(WORequest aRequest) public WOActionResults defaultAction() public WOActionResults studentAction() public WOActionResults adminAction() public WOActionResults staffAction()
NOTE: the only word that is common in all these methods is "Action" or "action"
Also please use only grep if possible :)
grep
command on the output ofjavap -private DirectAction.class
instead ofDirectAction.java
, because that will give you just the method names. (javap is a printer for java bytecode.)