linux touch command

The touch command of linux is not commonly used. Generally, it may be used when using make to modify the file timestamp or create a new file that does not exist.

  1. Command format:

    touch [options]... file...

  2. Command parameters:

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

    -c or --no-create do not create any documentation

    -d use the specified datetime instead of the current time

    -f This parameter will be ignored and will not be processed. It is only responsible for solving the compatibility problem of the touch command of the BSD version. It is rare to see a -f shriveled. It has never been ignored by others, and it has finally been ignored by others. ^^

    -m or --time=mtime or --time=modify only change the change time. -------To be honest, I don't know what this function is really useful for, if anyone of you knows, please let me know.

    -r Set the date and time of the specified document or directory to be the same as the date and time of the referenced document or directory.

    -t use the specified datetime instead of the current time

  3. Command function:

    The touch command parameter can change the date and time of the document or directory, including the access time and change time

  4. Example of use:

    Example 1: Create a file that does not exist  

    Order:

      touch 001.log 002.log creates two log files 001 and 002 at a time

      touch -c 003.log If 003 does not exist, the file is not created. If 003 exists, the time will be updated to prove that it has been touched. -----What is the use of this command? I said it was weird.  

  Example 2: The time to update 001.log is the same as the timestamp of 002.log

  Order:    

    touch -r 001.log 002.log

  Example 3: Setting the timestamp of the file

  Order:

    touch -t 000001010000 001.log The time is set at 000001010000. It cannot be all zeros or negatives. It is no wonder that people in BC do not surf the Internet.

    -t time Use the specified time value, time as the new value of the relative timestamp of the specified file. Here time is specified as a decimal number of the following form:

      [[CC]YY]MMDDhhmm[.SS]

      Here, CC is the first two digits of the number of years, that is, the "century number"; YY is the last two digits of the number of years, that is, the number of years in a century. If CC is not given, touch will limit the year CCYY to 1969--2068, where MM is months, DD is days, hh is hours, mm is minutes, and SS is seconds. The setting range for seconds here is 0-61, which can handle leap seconds. The time made up of these numbers is a time in the time zone specified by the environment variable TZ. Times earlier than January 1, 1970 are wrong due to system limitations. The system I use is modified, all will appear 000001010000

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325548814&siteId=291194637