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 "$@"
}

댓글 없음:

댓글 쓰기

구글 I/O 2025의 주요 발표

 구글 I/O 2025: 혁신의 현장 안녕하세요! 오늘은 구글 I/O 2025에 대해 이야기해보려고 해요. 매년 많은 기술 애호가들과 개발자들이 기다리는 이 행사에서 어떤 혁신이 있었는지, 그리고 앞으로의 기술 발전에 대해 알아보도록 할게요. 😊 구...