UNIX에서 파일의 mtime을 수동으로 업데이트

UNIX에서 파일의 mtime을 수동으로 업데이트

UNIX 시스템에서 파일 날짜를 이전 날짜로 수동으로 변경할 수 있습니까?

그렇다면 이 문제를 어떻게 해결해야 할까요?

동시에 여러 파일에 대해 동일한 작업을 어떻게 수행할 수 있습니까?

답변1

터치를 사용할 수 있습니다. 예::

touch -d '2007-01-31 8:46:26' file

또는 더 쉽게, 이미 mtime이 있는 file2가 있는 경우 -r을 사용하여 시간을 복사할 수 있습니다.

touch -r file2 file

이상한 형식의 -t 옵션도 있습니다:

touch -t [[CC]YY]MMDDhhmm[.ss] file

답변2

당신이 사용할 수있는

 touch -m -d '1 Jan 2006 12:34' test.txt

-m 수정 시간만 변경 -d (--date=STRING) 입력하려는 날짜로

매뉴얼에서 추출 :

DATE STRING
       The  --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday".  A
       date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers.  An empty  string  indicates
       the beginning of the day.  The date string format is more complex than is easily documented here but is fully described in the info documentation.

자세한 내용은 터치 매뉴얼, 런닝 맨 터치를 읽어보세요.

그게 도움이 됐으면 좋겠어.

관련 정보