C Voice Implementation Linux Touch command

Source: Internet
Author: User
Tags touch command

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.