Click Back to learn the path of the Linux command line and shell script
3.4-File Processing command touch CP MV RM
1. touch命令
一是用于把已存在文件的时间标签更新为系统当前的时间(默认方式),它们的数据将原封不动地保留下来;
二是用来创建新的空文件。
Touch (options) (parameters)
Options
- -A: or--time=atime or--time=access or--time=use only change the access time;
- -C: Or--no-create does not create any files or if the file does not exist.
- -d:< Time Date > Use the specified date time, not the current time;
- -F: Attempts to force Touch to run, regardless of the file's read and write permissions;
- -M: or--time=mtime or--time=modify only the change time;
- -r:< reference file or directory > set the date and time of the specified file or directory to the same date and time as the reference file or directory;
- -t:< Date Time > Use the specified datetime, not the current time;
- --help: Online Help;
- --version: Displays version information.
Parameters
File: Specifies the list of files for which you want to set time properties.
Note:
- The touch command calls the Utime () subroutine to change the modification and access time of the files involved. When you do not actually own the file, even if you have write permission to the file, the use of the flag may cause the Touch command to fail.
- When using the Touch command, if you receive an error message, do not specify the full pathname /usr/bin/touch.
Example 1 Touch file This sets the last access and modification time of the file to the current date and time. If the file does not exist, theTouch command creates an empty file with the same name.
Example 2 touch-c file avoid creating new files
Example 3 touch-c-t time file name explicitly set access and modification times
Example 4 touch-r file name 1 file name 2 to use the timestamp of another file without the current time
Self-study linux shell3.4-file processing command touch CP MV RM