cancel
Showing results for 
Search instead for 
Did you mean: 
Tahaik
Mission Specialist
Mission Specialist
  • 2,368 Views

Touch command

Hi I wante to know more about touch command agurment
For example
Touch -d "1 June 2008 11:02" file1
Touch -t 06011102 file1
Any practical real scenario will we uses this -t and -d
Because in my day to day I didn't use -d and -t.
Labels (1)
0 Kudos
1 Reply
EmanuelHaine
Flight Engineer
Flight Engineer
  • 2,325 Views

Hello Tahaik,

First of all, the most important thing that we have to put in mind is: "the touch command wasn't made for creating files". I know there is a lot of people that use this command for this task, but that is not its function.

So, about the options, the difference between 'd' and 't' is that on the option 'd' you must to give the argument on a string format and while the 't' option not.

On the man page you can make sure of that:

-d, --date=STRING
parse STRING and use it instead of current time

-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time

And of course, you illustrated very well in your description.

I believe here the difference is very thin and it will depend on the way you work or if you have a script for it.

On my job, it is very rare to use this command with the real purpose but there was a situation when an employee uploaded some photos to our file sharing and the date form the camera was wrong, it was one year forward and because this our backup system backed up theses files every day until we notice that. So we had to use the touch command.

Just to remember: when you want to see the detailed changes made by the touch command you can use the "stat" command. For example:

touch -t 1912240845 file1

stat file1
File: file1
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 2eh/46d Inode: 137352 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/emanuel.haine) Gid: ( 1000/emanuel.haine)
Access: 2019-12-24 08:45:00.000000000 -0300
Modify: 2019-12-24 08:45:00.000000000 -0300
Change: 2020-07-04 09:51:21.375462952 -0300
Birth: -

 

 

0 Kudos
Join the discussion
You must log in to join this conversation.