SRE/Linux Basics

touch

게임이 더 좋아 2022. 12. 31. 23:32
반응형
728x170

touch의 목적은 별 거 없다.

to create, change, or modify the timestamps of a file or directory in a Linux or Unix-like operating system

결국 timestamp 수정이다.

 

임시 파일 생성

1)크기가 0인 파일을 생성하거나, 2)같은 이름의 파일이 존재하는 경우 최종 수정시간을 바꾼다.

touch abc.txt

옵션을 지정하면 특정 시간을 바꿀 수 있다.

touch -d "2022-12-31 11:59:59" myfile.txt

 

 

Options

  • -a: Changes the access time of the file.
  • -c: Does not create a new file if the specified file does not exist.
  • -d: Sets the timestamp of the file to a specific date and time, specified in the format "YYYY-MM-DD HH:MM:SS".
  • -m: Changes the modification time of the file.
  • -r: Sets the timestamp of the file to match the timestamp of another file.
  • --reference=FILE: Same as -r, sets the timestamp of the file to match the timestamp of the specified file.
  • --time=WORD: Sets the timestamp of the file using one of the following keywords: access, atime, use, creation, or ctime.
반응형
그리드형

'SRE > Linux Basics' 카테고리의 다른 글

Symblic Link, Hard Link  (0) 2023.01.04
Register Service, 서비스 등  (0) 2023.01.04
Access Control Lists, ACLs  (0) 2022.12.30
rmdir  (0) 2022.12.25
mkdir  (1) 2022.12.25