Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个可以工作的命令,grep -r sometext .但它会知道查看档案(至少.jar)。
grep -r sometext .
.jar
额外奖励 ;) 如果我们可以让它忽略像.svn .hg.
.svn
.hg
低技术解决方案:
find . -name "*.jar" -exec jar tf '{}' \| grep -H "SearchTerm" \;
如果您经常这样做,请考虑将 grep 替换为ack(此外,它确实避免了默认的版本控制目录)
要在档案(例如 zip、tar、pax、jar)中搜索,带有选项的开源ugrep-z工具正是这样做的:
-z
ugrep -z "sometext" file.jar