Last Update 2014/03/11
ファイルのアクセス時刻と修正時刻を変更します。
※ オプションなどは個人的に重要と考えられるものを記述しており、記載の無いものは、manページや関連書籍などを参照願います。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。
(例)オプション無し
実行結果
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:15:59.249655298 +0900
Modify: 2014-02-02 13:15:59.249655298 +0900
Change: 2014-02-02 13:15:59.249655298 +0900
Birth: -
$ touch test.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:16:08.649706521 +0900 ←全ての時刻が変更
Modify: 2014-02-02 13:16:08.649706521 +0900 ←
Change: 2014-02-02 13:16:08.649706521 +0900 ←
Birth: -
実行結果
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:16:08.649706521 +0900
Modify: 2014-02-02 13:16:08.649706521 +0900
Change: 2014-02-02 13:16:08.649706521 +0900
Birth: -
$ touch -a test.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:17:02.397973275 +0900 ←変更
Modify: 2014-02-02 13:16:08.649706521 +0900
Change: 2014-02-02 13:17:02.397973275 +0900 ←変更
Birth: -
実行結果
$ ls -l
total 4
-rw-r--r-- 1 ******* ******* 5 Feb 2 13:16 test.txt
$ touch test2.txt
$ ls -l
total 4
-rw-r--r-- 1 ******* ******* 5 Feb 2 13:16 test.txt
-rw-r--r-- 1 ******* ******* 0 Feb 2 13:20 test2.txt
$ touch -c test3.txt ←新規には作成しない
$ ls -l
total 4
-rw-r--r-- 1 ******* ******* 5 Feb 2 13:16 test.txt
-rw-r--r-- 1 ******* ******* 0 Feb 2 13:20 test2.txt
実行結果
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:17:02.397973275 +0900
Modify: 2014-02-02 13:16:08.649706521 +0900
Change: 2014-02-02 13:17:02.397973275 +0900
Birth: -
$ touch -m test.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:17:02.397973275 +0900
Modify: 2014-02-02 13:41:39.325280484 +0900 ←変更
Change: 2014-02-02 13:41:39.325280484 +0900 ←変更
Birth: -
実行結果
$ ls -l
total 4
-rw-r--r-- 1 ******* ******* 5 Feb 2 13:41 test.txt
-rw-r--r-- 1 ******* ******* 0 Feb 2 13:20 test2.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:17:02.397973275 +0900
Modify: 2014-02-02 13:41:39.325280484 +0900
Change: 2014-02-02 13:41:39.325280484 +0900
Birth: -
$ stat test2.txt
File: `test2.txt'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fc00h/64512d Inode: 4592061 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:20:37.539033814 +0900
Modify: 2014-02-02 13:20:37.539033814 +0900
Change: 2014-02-02 13:20:37.539033814 +0900
Birth: -
$ touch -r test2.txt test.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:20:37.539033814 +0900 ←変更
Modify: 2014-02-02 13:20:37.539033814 +0900 ←変更
Change: 2014-02-02 13:53:42.000889150 +0900
Birth: -
$ ls -l
total 4
-rw-r--r-- 1 ******* ******* 5 Feb 2 13:20 test.txt
-rw-r--r-- 1 ******* ******* 0 Feb 2 13:20 test2.txt
実行結果
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-02-02 13:20:37.539033814 +0900
Modify: 2014-02-02 13:20:37.539033814 +0900
Change: 2014-02-02 13:53:42.000889150 +0900
Birth: -
$ touch -t 201401010000 test.txt
$ stat test.txt
File: `test.txt'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 4592073 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ *******) Gid: ( 1000/ *******)
Access: 2014-01-01 00:00:00.000000000 +0900 ←変更
Modify: 2014-01-01 00:00:00.000000000 +0900 ←変更
Change: 2014-02-02 14:01:56.335323974 +0900
Birth: -