Search code examples
bashunixunix-timestamp

Giving a file/directory the same modification date as another


How do I "copy" the modification date and time from one file/dir to another in Unix-based systems?


Solution

  • You have some options:

    • Use touch -t STAMP -m file if you want to change the time
    • Use cp --preserve=timestamps if you're copying the files and want to preserve the time
    • Use touch -r to set the time to a "reference" file