The Linux Touch command is used to modify the file timestamp, or to create a new file that does not exist, using the following method:
Touch [-acm][-r ref_file (Reference file) |-t time (value)] File (file name)
[-ACM] options for implementing Linux Touch commands based on C speech
Note:
Touch file1.txt update file1.txt access and modification times
Touch-a file1.txt Change the read time record of the File1.txt
Touch-c file1.txt If File1.txt does not exist, the file is not created
Touch-m file1.txt Change the modified time record of file1.txt
Knowledge point 1: function int getopt (int argc,char * Const ARGV[],CONST char * optstring); Included in header file #include <unistd.h> function: Open and create files
int open (constchar*pathname, int flags);
int open (constchar*pathname,int flags,mode_t mode);
Return value: Success returns the file descriptor, otherwise returns-1
Parameter description: For the Open function, the third parameter is used only when a new file is created (that is, when o_creat is used) to specify the access permission bit for the file
POSIX pathname to open/create file when pathname
Flags used to specify the opening/creation of files love you mode,
This parameter can be composed of the following constants (defined by fcntl.h) through logical bits or logic.
O_rdonly read-only mode
O_wronly Write-only mode
O_RDWR Read/write mode
C Voice Implementation Linux Touch command