: [root@dec q1]# ls -al |wc -l
: 40929
:
: 파일 개수가 40929개가 있습니다.
:
: 전부 지우고 싶습니다.
:
: [root@dec q1]# rm -f *
: bash: /bin/rm: Argument list too long
: [root@dec q1]# rm -f q*
: bash: /bin/rm: Argument list too long
: [root@dec q1]# rm -f d*
: bash: /bin/rm: Argument list too long
:
: 어떻게 하면 지울 수 있을까요?
:
: --
: N/A
그냥 프로그램 하나 간단하게 만드세요~
아래거는 파일 엑세스타임이 3일이 지난것들 지우는 프로그램입니다.
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
int main (int argc,char *argv<>)
{
DIR *dp;
struct dirent *dirp;
struct stat buf;
time_t ctm;
long count=0;
dp=opendir("/path");
ctm = time(NULL);
while ( (dirp = readdir(dp)) != NULL){
printf("%s",dirp->d_name);
stat(dirp->d_name,&buf );
printf("시간 = %ld ",buf.st_atime);
if (buf.st_atime <(ctm - 86400 * 3 ) && (strncmp(dirp->d_name,"run",3) != 0)
&& (strncmp(dirp->d_name,"dir.c",5) != 0)){
printf("%s --->삭제됨",dirp->d_name);
unlink(dirp->d_name);
count ++;
}
}
closedir(dp);
printf(" 총 %ld 개의 파일이 삭제 되었습니다.",count);
exit(0);
}--용사란 그저 그런 사람들이지.
싸움은 전사가 잘하고, 마법은 마법사가 잘 걸거든.
용사가 가진것은 어떠한 것에도 덤벼드는 무모할 정도의 용기야..
- 타이의 대모험 중에서 -