Touch: Update file time or create a blank file
1. Command format
Touch [options] File
2. Command function
The intent is to update the timestamp of the file, which is now used to create a blank file.
3. Command parameters
-A: Change access time only
-M: Change only the modified time
-C: Do not create any files
-T: Use the specified date and time instead of the current time
4. Command instances
Example 1: Create a blank file that does not exist
[email protected] ~]# Touch file1
[[email protected] ~]# ls
AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog
Example 2: Changing the access time
[Email protected] ~]# stat file1
File: ' File1 '
size:0 blocks:0 IO block:4096 Regular empty file
device:803h/2051dinode:2709265 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2014-12-21 17:02:49.000000000 +0800
Modify:2014-12-21 17:02:49.000000000 +0800
Change:2014-12-21 17:02:49.000000000 +0800
[Email protected] ~]# touch-a file1
[Email protected] ~]# stat file1
File: ' File1 '
size:0 blocks:0 IO block:4096 Regular empty file
device:803h/2051dinode:2709265 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2014-12-21 17:05:37.000000000 +0800
Modify:2014-12-21 17:02:49.000000000 +0800
Change:2014-12-21 17:05:37.000000000 +0800
Example 3: Change the modification time
[Email protected] ~]# stat file1
File: ' File1 '
size:0 blocks:0 IO block:4096 Regular empty file
device:803h/2051dinode:2709265 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2014-12-21 17:05:37.000000000 +0800
Modify:2014-12-21 17:02:49.000000000 +0800
Change:2014-12-21 17:05:37.000000000 +0800
[Email protected] ~]# touch-m file1
[Email protected] ~]# stat file1
File: ' File1 '
size:0 blocks:0 IO block:4096 Regular empty file
device:803h/2051dinode:2709265 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2014-12-21 17:05:37.000000000 +0800
Modify:2014-12-21 17:07:48.000000000 +0800
Change:2014-12-21 17:07:48.000000000 +0800
Example 4: Do not create any files
[[email protected] ~]# ls
AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog
[Email protected] ~]# touch-c file2
[[email protected] ~]# ls
AA ABC anaconda-ks.cfg Desktop file1 gg install.log install.log.syslog
Example 5: Using the specified time
[Email protected] ~]# touch-t 201412211712.30 file2
[Email protected] ~]# stat file2
File: ' File2 '
size:0 blocks:0 IO block:4096 Regular empty file
device:803h/2051dinode:2709266 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
Access:2014-12-21 17:12:30.000000000 +0800
Modify:2014-12-21 17:12:30.000000000 +0800
Change:2014-12-21 17:13:20.000000000 +0800
This article is from the "cold-blooded Killer" blog, please be sure to keep this source http://deathkiller.blog.51cto.com/9130248/1592314
The touch of Linux common commands