unix how to change file date and timestamp

 

There are several several ways we can control the file timestamp on unix systems, touch command is useful to modify file to specific timestamp for:

1. access time

2. modified time

usage: touch option filename(s)

options:

-a = modify only access time

-m = modify only modified time

-r = reference copy the timestamp from file1 to file2

-d = add specifc timestamp to file

-t = add specific timestamp same as -d option but with different format 

$> touch -d '1 May 2014 10:22' file1

$> touch -d '14 May' file1 [ default time to 00:00 ]

$> touch -d '14:24' file1 [ default date to current date ]

$> touch -t 201307030300 foo.txt [ date format= [[CC]YY]MMDDhhmm[.ss] ] 

File stat:

$> stat file1

 

 

 

 

 

 

Who's new

  • admin

Who's online

There are currently 0 users online.