티스토리 뷰

 

 

[linux][touch 파일의 날짜시간정보 변경]


touch는 파일의 날짜시간정보를 변경하는 명령어이다. 

즉 아무런 옵션이 없다면 파일의 최근에 사용한 시간과 최근에 변경된 시간을 서버의 현재시간으로 변경한다.

만약 지정된 명령어가 존재하지 않는다면 파일의 크기가 0인 빈 파일을 생성한다.



[옵션]

-t : 서버의 현재시간이 아닌 지정된 시간으로 파일의 날짜시간정보를 변경한다.

-c : 존재하지 않은 파일일 경우에는 파일을 생성하지 않는다.

-r : 특정파일의 날짜시간정보를 다른파일에 동일하게 변경한다.



# 명령어 사용형식


touch [옵션] [-r file] [-t MMDDhhmm[[CC]YY][.ss]] [-d  time]

[--time={atime,access,use,mtime,modify}]   [--date=time]   



# 사례 1)

# 아무런 옵션없이 파일이름만 지정하면 서버의 현재시간을 가진 비어있는 파일을 생성한다.

[root@host1 commmand]# touch file1

[root@host1 commmand]# ls -l

합계 0

-rw-r--r--    1 root     root            0  9월 10 13:05 file1

[root@host1 commmand]#



# 사례 2)

# 특정 파일의 날짜시간을 지정된 날짜시간정보로 변경하는 예이다.

[root@host1 commmand]# ls -l

합계 0

-rw-r--r--    1 root     root            0  9월 10 13:05 file1

[root@host1 commmand]# 

[root@host1 commmand]# touch -t 09100111 file1

[root@host1 commmand]#

[root@host1 commmand]# ls -l

합계 0

-rw-r--r--    1 root     root            0  9월 10 01:11 file1

[root@host1 commmand]#

 


# 사례 3)

# 특정파일의 날짜시간정보를 이용하여 지정된 파일의 날짜시간정보를 변경하는 예이다.


[root@host1 commmand]# ls -l

합계 0

-rw-r--r--    1 root     root            0  3월  5  2003 file1

-rw-r--r--    1 root     root            0  9월 10 13:05 file2

[root@host1 commmand]# 

[root@host1 commmand]# touch -r file1 file2

[root@host1 commmand]# ls -l

합계 0

-rw-r--r--    1 root     root            0  3월  5  2003 file1

-rw-r--r--    1 root     root            0  3월  5  2003 file2

[root@host1 commmand]#




<참고>

https://www.linux.co.kr/home/lecture/?leccode=10547




[linux][awk 명령어] ----


awk는 직접 사용자로부터 입력을 받거나 아니면 지정한 파일을 가공하여 표준 출력한다

표준 출력을 리다이렉션할 수 있다




<참고>

http://community.365managed.com/?document_srl=284


 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함