Linux touch command
Linux touch command is used to modify the time attributes of a file or directory, including access time and change the time. If the file does not exist, the system creates a new file.
ls -l to display the file time records.
grammar
touch [-acfm][-d<日期时间>][-r<参考文件或目录>] [-t<日期时间>][--help][--version][文件或目录…]
- Parameter Description:
- a change in reading time record file.
- m change modify file time records.
- c If the object file does not exist, does not create a new file. And --no-create the same effect.
- f not used for compatibility with other unix system reserved.
- r time record reference profile, and --file the same effect.
- d set the time and date, you can use a variety of formats.
- t set the file time records, in the same format and date instruction.
- --no-create do not create new files.
- --help lists the instruction formats.
- --version Lists version information.
Examples
Using the command "touch" to modify the file "testfile" time attribute to the current system time, enter the following command:
$ touch testfile #修改文件的时间属性
First, use the ls command to view properties testfile file, as follows:
$ ls -l testfile #查看文件的时间属性 #原来文件的修改时间为16:09 -rw-r--r-- 1 hdd hdd 55 2011-08-22 16:09 testfile
After the instruction is executed "touch" modify file attributes, time and again to view the file's properties, as follows:
$ touch testfile #修改文件时间属性为当前系统时间 $ ls -l testfile #查看文件的时间属性 #修改后文件的时间属性为当前系统时间 -rw-r--r-- 1 hdd hdd 55 2011-08-22 19:53 testfile
When using the command "touch", if the specified file does not exist, create a new blank document. For example, in the current directory, use this command to create a blank file "file", enter the following command:
$ touch file #创建一个名为“file”的新的空白文件