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

댓글 없음:

댓글 쓰기

재산세

재산세에 대한 정보입니다. 재산세는 개인이나 기업이 소유한 재산에 대해 부과되는 세금으로, 주로 부동산에 대한 세금이 포함됩니다. 이 세금은 지방자치단체의 재정 수입원 중 하나로, 지역 사회의 발전과 공공 서비스 제공에 중요한 역할을 합니다. 재산세란...