가끔 하늘을 보자: Linux find 명령 활용한 파일내 string 찾기

2014년 8월 27일 수요일

Linux find 명령 활용한 파일내 string 찾기

안드로이드 envsetup.sh 파일을 참고하여 작성된 function.

아래 파일을 sh 파일로 저장후 cygwin 이나 Linux 환경에서 동작.

". filename.sh" 실행후, functionName string 으로 사용.


function jgrep()
{
find . -name .repo -prune -o -name .git -prune -o  -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
}

function cgrep()
{
find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
}

function resgrep()
{
for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
}

function mangrep()
{
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
}

function sepgrep()
{
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@"
}

function allgrep()
{
find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.java' -o -name 'AndroidManifest.xml' -o -name '*.xml' -o -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
}

댓글 없음:

댓글 쓰기

GPT-5와 Sora 2 API, 그리고 ChatGPT Apps: 오픈AI가 제시한 AI 혁명

                     🎯 GPT-5와 Sora 2 API, 그리고 ChatGPT Apps: 오픈AI의 **AI 혁명** 핵심 정리!     AI 혁명의 진짜 주인공은 이제야 등장했어요.     GPT-4나 GPT-4o만 해도 엄청난 ...