From 524c81460dd9f8f50ff2818cb1d7fbe37f9dbdbb Mon Sep 17 00:00:00 2001 From: Asocia Date: Sat, 3 Jul 2021 17:27:38 +0300 Subject: [PATCH] TIL: Changing the modification date of a file --- .../changing-the-modification-date-of-a-file.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 bash-scripting/changing-the-modification-date-of-a-file.md diff --git a/bash-scripting/changing-the-modification-date-of-a-file.md b/bash-scripting/changing-the-modification-date-of-a-file.md new file mode 100644 index 0000000..87a0e69 --- /dev/null +++ b/bash-scripting/changing-the-modification-date-of-a-file.md @@ -0,0 +1,14 @@ +You can use `touch` to change modification date or time of a file: +``` +touch -d 20210703 filename + +# Set the times on a file to a specific date and time: +touch -t YYYYMMDDHHMM.SS filename +``` + + +or use the times from a file to set the times on a second file: + +``` +touch -r filename filename2 +```