Skip to content

NOWWORKINGON

touch command

  • on a non-existing file : create a new empty file
  • on an existing file : change time stamps

Be careful with changing time stamps : backup and sync tools -and others- may take incorrect decesions when timestamps have been changed.
It is not possible to change the ctime using touch command, only when creating a new file.

parameters
-t : specify the detetime stamp
-a : acces time
-m : modified time
example : set mtime and acces time stamps to : 2017-01-31 12: 00

stat {filename}
touch -a -t 201701311200 {filename}
touch -m -t 201701311200 {filename}
# or combined : 
touch -a -m -t 201701311200 {filename}
201701311200.07    => 07 seconds
stat {filename}

the stroke utility

has a lot more options
install :
- dl from http://stroke.sourceforge.net/
- extract archive
- compile the tool

cd /mnt/data/install/stroke-0.1.3/   
./configure
make
sudo make install
  • run
    => make errors #TODO

examples
- stroke mM=aM=3 .jpg
set the month value of access and modification time of all `
.jpg’ files in the current directory is changed to 3 (March).
- stroke -ctime cY=mY,cM=mM,cD=mD,ch=ah=mh < file>
Set a file’s change time date components equal to those of its modification time. Moreover, set its change time and access time hour component equal to that of its modification time.
- stroke -preserve mY=aY=++,mM=aM=-2 < file>
Increment a file’s modification and access time year value by one and decrement its modification and access time month value by 2 while preserving the file’s change time at it its original value.
- stroke -c -s 0005132305.23:mac < file>
Set a files modification, access, and change time to the date indicated by the time stamp given; this would be the 13th of May 2000, at 11:05:23 pm.