#!/usr/bin/perl
# SearchToNotUsePng.pl
# seesky89 20140826
# usage :
# Android Application 개발시 사용하지 않는 png 이미지 제거를 위해 만듬.
# cgywin(for Windows) 또는 리눅스에서 아래 명령 입력(상위 폴더기준)
# perl SearchToNotUsePng.pl
# 정확성을 위해 gen, bin 폴더는 삭제 필요.
use strict;
use warnings;
use File::Find;
use File::Find qw(find);
use Cwd;
my $dir = '.';
open FH, ">", "result.txt" or die "$!\n";
my $mainDir = getcwd;
print FH "Search to not use resource. you need to check.\n";
print FH $mainDir, "\n";
print FH "------------------------------------------------------------\n";
find(\&find_use_file, $dir);
close FH;
print ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n";
print "Check to result.txt\n";
print ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n";
sub find_use_file {
my $file = $_;
my $currentDir = getcwd;
if (-d $file) {
#print "skip dir : $file\n";
} elsif (-f $file) {
#print "file : $file\n";
if (/\b.9.png\b/i) {
print "search file : $File::Find::name\n";
# filename.png
my $lastindex = rindex($file, '.9');
my $search = substr($file, 0, $lastindex);
$currentDir = getcwd;
chdir('../..');
my $ret = system("find . -name -prune -o -type f \( -name '*.java' -o -name '*.xml' -o -name '*.c' \) -print0 | xargs -0 grep --color -n $search");
if($ret != 0) {
print FH $File::Find::name, "\n";
}
chdir($currentDir);
} elsif (/\b.png\b/i) {
print "search file : $File::Find::name\n";
# filename.png
my $lastindex = rindex($file, '.');
my $search = substr($file, 0, $lastindex);
$currentDir = getcwd;
chdir('../..');
my $ret = system("find . -name -prune -o -type f \( -name '*.java' -o -name '*.xml' -o -name '*.c' \) -print0 | xargs -0 grep --color -n $search");
if($ret != 0) {
print FH $File::Find::name, "\n";
}
chdir($currentDir);
} else {
#print "skip other file : $file\n";
}
}
}
2014년 8월 27일 수요일
Perl 사용하지 않는 png 이미지 찾기
사용하지 않는 png 이미지 찾아 result.txt 로 출력하는 perl.
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 "$@"
}
아래 파일을 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 "$@"
}
피드 구독하기:
글 (Atom)
GPT-5와 Sora 2 API, 그리고 ChatGPT Apps: 오픈AI가 제시한 AI 혁명
🎯 GPT-5와 Sora 2 API, 그리고 ChatGPT Apps: 오픈AI의 **AI 혁명** 핵심 정리! AI 혁명의 진짜 주인공은 이제야 등장했어요. GPT-4나 GPT-4o만 해도 엄청난 ...

-
https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter # 안드로이드 ListAdapter 사용하기: 효율적인 RecyclerView 업데이트 안드로이드 개발에서...
-
메모리 사용량 알기 1 - heap Runtime runtime = Runtime. getRuntime (); long maxMemory = runtime.maxMemory(); long totalMemory = runtim...
-
⚡ 민생회복 소비쿠폰, 2025년 최신 정보! 신청부터 사용까지 완벽 가이드 솔직히 저도 처음에 이거 받으면서 엄청 헤맸거든요. 온라인 신청은 어디서 하는지, 누가 얼마나 받는지부터 사용처까지 헷갈리는 게 한두 개가 아니었어요. 여러분도 혹시 저처...