aosp 单独grep某种类型文件,加快grep速度。

1、问题
source build/envsetup.sh
lunch xxx
后可以
mgrep 可以单独搜索makefile文件
cgrep 可以单独搜索c/c++文件
jgrep 可以单独搜索java文件

具体可以查看build/envsetup.sh

cat build/envsetup.sh
function jgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" \
        -exec grep --color -n "$@" {} +
}

function cgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) \
        -exec grep --color -n "$@" {} +
}

或者敲hmm

user@host:~/work/aosp$hmm

- cgrep:      Greps on all local C/C++ files.
- ggrep:      Greps on all local Gradle files.
- gogrep:     Greps on all local Go files.
- jgrep:      Greps on all local Java files.
- resgrep:    Greps on all local res/*.xml files.
- mangrep:    Greps on all local AndroidManifest.xml files.
- mgrep:      Greps on all local Makefiles and *.bp files.
- owngrep:    Greps on all local OWNERS files.
- sepgrep:    Greps on all local sepolicy files.
- sgrep:      Greps on all local source files.
- godir:      Go to the directory containing a file.

然后,想单独搜索aidl或者python等,系统没有帮我们写,我们扩展一下。

二、解决
~/bin/mygrep

#!/bin/bash
function agrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.aidl" \
        -exec grep --color -n "$@" {} +
}

function hgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.hal" \
        -exec grep --color -n "$@" {} +
}

function xmlgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.xml" \
        -exec grep --color -n "$@" {} +
}

function inigrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.ini" \
        -exec grep --color -n "$@" {} +
}

function shgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.sh" \
        -exec grep --color -n "$@" {} +
}

function pygrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.py" \
        -exec grep --color -n "$@" {} +
}


使用方法
source ~/bin/mygrep
然后在aosp目录下,
agrep 可以单独搜索aidl文件
pygrep 可以单独搜索python文件
shgrep 可以单独搜索shell文件

如果有固态硬盘,当我没说。直接grep 或在repo grep 或者 git grep。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值