One linux command every day (9): touch Command

Source: Internet
Author: User
Tags touch command
One linux command every day (9): touch Command link: One linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html One linux command every day (9): touch Command link: One linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html ; One linux command every day (3): pwd command http://www.2cto.com/os/201210/163462.html ; One linux command every day (4): mkdir command http://www.2cto.com/os/201210/163463.html ; One linux command every day (5): rm command http://www.2cto.com/os/201210/163662.html ; One linux command (6) every day: rmdir command http://www.2cto.com/os/201210/164017.html ; One linux command (7) every day: mv command http://www.2cto.com/os/201210/164247.html ; One linux command every day (8): cp command http://www.2cto.com/os/201210/164254.html Linux touch commands are not commonly used. they are generally used when you use make to modify the file timestamp or create a new file that does not exist. Www.2cto.com 1. command format: touch [option]... file... 2. command parameters:-a or -- time = atime or -- time = access or -- time = use only change the access time. -C or -- no-create does not create any documents. -D uses the specified date and time instead of the current time. -F this parameter will not be processed. it is only responsible for solving the compatibility problem of the BSD touch command. -M or -- time = mtime or -- time = modify only changes the change time. -R sets the date time of the specified document or directory to the same as the date time of the reference document or directory. -T uses the specified date and time instead of the current time. Www.2cto.com 3. command function: touch Command parameters can change the date and time of the document or directory, including the access time and change time. 4. example: instance 1: run the "touch log2012.log log2013.log" command to create a non-existent file. output: [root @ localhost test] # touch log2012.log log2013.log [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 16:01 log2012.log-rw-r -- r -- 1 root 0 10-28 16:01 log2013.log if log2014.log does not exist, do not create a file [root @ localhost test] # touch-c log2014.log [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 01 log2012.log- rw-r -- 1 root 0 10-28 16: 01 log2013.log instance 2: update log. the log time is the same as that of log2012.log: touch-r log. log log2012.log output: [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 16:01 log2012.log-rw-r -- 1 root 0 10-28 16:01 log2013.log -rw-r -- 1 root 0 10-28 log. log [root @ localhost test] # touch-r log. log log2012.log [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 14:48 log2012.log-rw-r -- 1 root 0 10- 28 log2013.log-rw-r -- 1 root 0 10-28 log. log Example 3: Set the file timestamp command: touch-t 201211142234.50 log. log output: [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 14:48 log2012.log-rw-r -- 1 root 0 10-28 16:01 log2013.log -rw-r -- 1 root 0 10-28 log. log [root @ localhost test] # touch-t 201211142234.50 log. log [root @ localhost test] # ll-rw-r -- 1 root 0 10-28 log 2012. log-rw-r -- 1 root 0 10-28 16:01 log2013.log-rw-r -- 1 root 0 2012-11-14 log. log description:-t time uses the specified time value time as the new value of the corresponding time stamp of the specified file. the time here is defined as the following decimal number: [[CC] YY] MMDDhhmm [. SS] Here, CC is the first two in the number of years, that is, the number of centuries. YY is the last two in the number of years, that is, the number of years in a century. if no CC value is provided, touch limits the number of years CCYY to within 1969--2068. MM indicates the number of months. DD indicates the number of years CCYY is limited. MM indicates the number of months, DD indicates the number of days, hh indicates the number of hours (when), mm indicates the number of minutes, and SS indicates the number of seconds. the second is set to 0--61, which can process leap seconds. the time composed of these numbers is a time zone specified by the environment variable TZ. due to system restrictions The time of January 1, January 1, 1970 is incorrect.
Related Article

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.