Touch is a powerful tool that can be used to create and modify timestamps. Touch can be used to change the date, time, or even minutes. Touch can also be used to change the time zone. To use touch to create timestamps, first make sure you have the required tools. You will need a digital watch orwatch app, a stylus, and some paper. To create a timestamp, first touch the screen of your digital watch orwatch app and drag the date or time slider to the right. Then touch the blue check mark in the bottom left corner of the screen to confirm your timestamp creation. To modify a timestamp, first touch the screen of your digital watch orwatch app and drag the date or time slider to the left. Then touch one of the following buttons: (Date/Time) - This button changes how long ago or recently your timestamp was created (in seconds). The default is 0 seconds since 00:00:00 on January 1st, 1970.

  • This button changes how long ago or recently your timestamp was created (in seconds). The default is 0 seconds since 00:00:00 on January 1st, 1970. (Date/Time) - This button changes how long ago your timestamp is currently set (in days). The default is 7 days since December 15th, 2016.
  • This button changes how long ago your timestamp is currently set (in days). The default is 7 days since December 15th, 2016. (Date/Time) - This button changes how long ago your timestamp was last modified (in minutes). The default is now if no other buttons are touched while it’s active. If another button has been touched while this one is inactive, it becomes active again and updates as soon as possible after any new data has been added to it; however if this button has not been touched in

Every file on your computer has a timestamp, which contains the access and modification time for a file, but did you know that you can change that timestamp? Here’s how to do it.

Using the Touch Command

The “touch” command is available pretty much anywhere that you can get the Bash shell, which includes Linux or Windows with Cygwin installed. Here’s the options for the command:

If you want to check the file timestamp, you can do so with this command:

Obviously you should make sure to replace “file” with your file’s name.

-a and -m options

These two options update the access and modification time respectively. Using them should be no problem at all. Here is the syntax:

This will update “file”s access time to the current date and time. You can replace the (-a) options with (-m) to do the same but for the modification time. If the file doesn’t exist, an empty file with the same name will be created in the current directory.

-c option

If you use this option, touch won’t do anything at all if the file specified doesn’t exist. Look:

In the above example touch will do nothing as “omar”, the file not the person, doesn’t exist.

-r option

This option might come in handy if you want to copy a timestamp from a file to another file. Like so:

Where “file1” is the reference file and “file2” is the file that will be updated. If you want to copy the timestamp to more than one file you can provide them all in the command as well and they will be created simultaneously.

-d and –t options

Both (-d) and (-t) options do the same thing, which is setting the same arbitrary timestamp for access and modification times. The difference is that (-d) uses free format human readable date, this means that you can use “Sun, 29 Feb 2004 16:21:42” or “2004-02-29 16:21:42” or even “next Thursday”. This option is complex to fully describe it here. On the other hand (-t) uses a simple stamp that you are confined to use. The stamp is [[CC]YY]MMDDhhmm[.ss]. [CC] is for century and you may ignore it and ignore the seconds as well. If you ignore [CC] the command will substitute it depending on what you enter as year. If you specify the year with only two digits, then CC is 20 for years in the range (0~68) and 19 for years in (69~99).

In the first command the file timestamps will be set to: 15th April 2034 10:40 PM. While the second command will set it to: 15th April 1988 which is in a different century. If no year is specified it will be set to the current year. Example:

touch –t 8804152240 file

This will set the timestamp to 15th April 2011 10:40 PM because it is 2011 by the time of writing this article.

Combining Options to Set Arbitrary Individual Access and Modification Times

The (-a) and (-m) options only updates the timestamps to current time and the (-d) and (t) options sets both access and modification timestamps to the same time. Assume you only only want to set the access time to the 5th of June 2016 at 5:30 PM, How would you do that? Well, you’ll use (-a) and (-t) to both set an arbitrary time and apply it only for the access timestamp. Example:

or

And if you want to do the same for the modification time just substitute (-at) with (-mt). It’s easy.

Creating Empty Files

The second and most famous usage of the touch command is creating empty files. This might sound stupid, why would anyone sensibly overload his computer with empty nonsense files but it really comes to use when, for example, you are working on a project and want to keep track of progress with dates and times. So you’ll have a folder with the project’s name and use touch to create empty files with the events as names of file. In other words, you can use it to create logs. Example:

Now you have a file signifying the completion of stage 1 of the project at the time of creating this file and you can see this time by issuing the command:

 

You can find touch useful in different ways depending on what you do. If you know more good uses for touch then share it in the comments or read more about the touch command by visiting its man page online or in a terminal by issuing the command “man touch”.