Structural grep
When you want to grep some information from a structured document, like code, configuration file, the result may disapoint you:
$ grep mockito pom.xml --color <mockito-all.version>1.9.0</mockito-all.version> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>${mockito-all.version}</version> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId>
Lack of context makes the results hard to read.
Try sgrep
:
$ sgrep mockito pom.xmlpom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <properties> 889: <mockito-all.version>1.9.0>/mockito-all.version> </properties> <dependencyManagement> <dependencies> <dependency> 1325: <groupId>org.mockito>/groupId> 1326: <artifactId>mockito-all>/artifactId> 1327: <version>${mockito-all.version}>/version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> 1360: <groupId>org.mockito>/groupId> 1361: <artifactId>mockito-all>/artifactId> </dependency> </dependencies> </project>
sgrep
analyze the structure of the document and give enough hierarchical context to let you know the position of the match text.
Apache License V2