One Linux command per day (9): Touch

Source: Internet
Author: User

1. Introduction to Commands

The Touch command changes the access time and modification time for each file to the current time.

2. Usage
Touch [Options] ... File...
3. Options
  -A            only change the access  time -C,--no-    Create creates no  file -D,--Date= string    Use the specified string to represent the time instead  of the current time -F  (Ignore)-H,--no-dereference affects the        symbolic link itself, not the destination indicated by the symbolic link (This option is useful when the system supports changing the owner of a symbolic link  .) -m            only changes the modified  time -R, the--reference= file    uses the specified file's time attribute  instead of the current time -t STAMP        uses the [ [CC] YY]MMDDHHMM[.SS] Format time instead of the current time   -time=word        using WORD: Access, atime, use equals-the effect of the-a option , while modify, Mtime equals The effect of the-m option
4. Instance 1: Create an empty file in the current directory A.log
Touch010 April  : A.log
Example 2: Update A.log modification time is current time
0 1 0 April  :touch01 0 April  : A.log
Example 3: Update Log1.log time and Log2.log timestamp same
[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April -  +: ,A.log-rw-r--r--1Root root0April -  +: AB.log[[email protected] dir1]#Touch-r a.log B.log [[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April -  +: ,A.log-rw-r--r--1Root root0April -  +: ,B.log
Example 4: Setting the timestamp of a file
[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April -  +: ,A.log[[email protected] dir1]#Touch-T201601011200.50Log.log[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April -  +: ,A.log-rw-r--r--1Root root0January1  A:xxLog.log

One Linux command per day (9): Touch

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.