find . -name "*Extent.java" -exec echo "{}," \; -exec grep " CLASSNAME" '{}' > output.xml \;
This is search all the files ends with "Extent.java", print the name, then grep the line which contains "ClASSNAME", then put everything into output.xml
snippet of output.xml
/advising/src/com/dovetailsys/advising/Q5CNPBankRestrictionExtent.java,
public static final String CLASSNAME = "CNPBankRestriction";
Showing posts with label Grep. Show all posts
Showing posts with label Grep. Show all posts
Unix Grep
grep "BusinessStatus" -B10 -A2 importList-Test.xml > output.xml
General meaning: get some stuff from importList-Test.xml, and put it into output.xml.
What stuff? lines which contain "BusinessStatus" + 10 lines before it + 2 lines after it.
This is very useful to extract certain patterned-contents from a large file.
find . -name "*Bean.java" -exec echo "==={}:" \; -exec grep "re\"DefaultDataSource\"" -B1 -A3 {} \;
find . -name "*Extent.java" -exec grep "CLASSNAME =" '{}' > output.xml \;
find . -name "*Bean.java" -exec echo "==={}:" \; -exec grep "re\"DefaultDataSource\"" -B1 -A3 {} \;
find . -name "*Extent.java" -exec grep "CLASSNAME =" '{}' > output.xml \;
Subscribe to:
Posts (Atom)