Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » CommandsRSS Feeds

Update access, modification, and / or change times of file - touch

Posted By: James Evans     Category: Unix / Linux / Ubuntu     Views: 3447

This article explains about touch command with an example in unix.

touch command is used to update access, modification, and /or change times of
file in unix.

• Usually, touch is used to create a new file.


Syntax of touch Command

touch [- option] filename  

Most Commonly used options are:
  • -a Change the access time of file. Do not change the modification time unless -m is also specified.
  • -c Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition.
  • -m Change the modification time of file. Do not change the access time unless -a is also specified.
  • -r ref_file Use the corresponding times of the file named by ref_file instead of the current time.
  • -t time Use the specified time instead of the current time. time will be a decimal number of the form : [[CC]YY]MMDDhhmm [.SS]
  • -f ref_file Use the corresponding times of the file named by ref_file instead of the current time.
  • file A path name of a file whose times are to be modified.

Example of touch Command

Example 1 : To create a zero-length file

touch myFile.txt
  
Share: 



James Evans
James Evans author of Update access, modification, and / or change times of file - touch is from London, United Kingdom.
 
View All Articles

 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!