One Linux command per day-touch

Source: Internet
Author: User

Linux is used in Linux systems to create files or to modify the timestamp of a file

    1. Command function:

      Create an empty file, or modify the timestamp of an existing file

    2. Syntax parameters:

-A or--time=atime or--time=access or--time=use only change access time

-C or--no-create does not create any files.

-d< Time Date > Use the specified datetime, not the current time.

-M or--time=mtime or--time=modify only change the modified 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 instead of the current time

-help Help Documentation

-version displaying version information

Command format: Touch [option] filename

Common examples:

Example 1: Create a file that does not exist.

Command:

Touch 1.txt

Output: Plus parameter-C does not create the file

[[email protected] test]# Touch 1.txt 2.txt 3.txt [[email protected] test]# ls 1.txt 2.txt 3.txt [[email protected] Test ]# touch-c 4.txt [[email protected] test]# ls 1.txt 2.txt 3.txt [[email protected] test]#

Example Two: Modify the last modified time of the existing file to current.

Command:

Touch Install.log

Output:

[email protected] ~]# ll install.log-rw-r--r--. 1 root root 34961 June 22:02 Install.log[[email protected] ~]# touch Install.log[[email protected] ~]# ll INSTALL.LOG-RW -r--r--. 1 root root 34961 June 15:17 Install.log[[email protected] ~]#

Example Three: Modify the timestamp of the install.log.syslog to the timestamp of the Install.log.

Command:

Touch-r Install.log Install.log.syslog

Output:

[email protected] ~]# ll Install.log install.log.syslog-rw-r--r--. 1 root root 34961 June 15:17 Install.log-rw-r--r--. 1 root root 7346 June 21:59 Install.log.syslog[[email protected] ~]# touch-r install.log install.log.syslog [[Email PR Otected] ~]# ll Install.log install.log.syslog-rw-r--r--. 1 root root 34961 June 15:17 Install.log-rw-r--r--. 1 root root 7346 June 15:17 Install.log.syslog[[email protected] ~]#

Example four: Setting the timestamp of the file, setting the Install.log.syslog file timestamp to bit 03211111

Command:

Touch-t 03211111 Install.log.syslog

Output:

[email protected] ~]# ll install.log.syslog-rw-r--r--. 1 root root 7346 June 15:17 Install.log.syslog[[email protected] ~]# touch-t 03211111 install.log.syslog [email Protec Ted] ~]# ll Install.log.syslog-rw-r--r--. 1 root root 7346 Mar 11:11 install.log.syslog[[email protected] ~]#


One Linux command per day-touch

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.