가장 오래된 파일을 찾는 쉘 스크립트

rma8806의 이미지


이렇게 사용하니 $LOG_DIR에서 가장 오래전에 접근한 파일을 반환 하더라고요..

OLDIST_FILE=`ls $LOG_DIR -1t | tail -1`

어떻게 하면 가장 오래된 파일을 찾을수 있을까요?

qiiiiiiiip의 이미지

리눅스에서는 아래 세개의 시간이 주로 쓰입니다.

access (read the file's contents) - atime
change the status (modify the file or its attributes) - ctime
modify (change the file's contents) - mtime

mount option에 따라 일부는 갱신이 안되는 경우도 있고요..

찾으시는 것은 파일의 생성날짜인것 같은데요..
간단한 방법은 없고, 아래의 링크를 참조하셔서 직접 스크립트를 작성하셔야할 듯..

http://unix.stackexchange.com/questions/91197/how-to-find-creation-date-of-file