touch Linux Commands

What is Linux touch Command?

Explanation

touch COMMAND:

touch command is used to update last modified time and date of a file. It is also used to create a new empty file with current date and time.

SYNTAX :


touch [options] File

OPTIONS:


-a update only the access time.
-B, --backward=SECONDS Modify the time by going back SECONDS seconds.
-c, --no-create do not create any files.
-d, --date=STRING parse STRING and use it instead of current time.
-m change only the modification time.
--time=WORD set time given by WORD: access atime use (same as -a) modify mtime (same as -m).
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time.

EXAMPLE:


  1. touch test.php
    Output:
    In the above example, the command checks whether the file test.php already exists. If exists, it just modifies the date and time of the file.
    Else, it creates a new file named 'test.php' with the current date and time.

Ask Questions

Ask Question