Date: Tue, 29 Sep 2020 13:40:51 +0200 From: Polytropon <freebsd@edvax.de> To: freebsd-questions@freebsd.org Subject: Re: Preserving target file's creation date Message-ID: <20200929134051.b17c0b48.freebsd@edvax.de> In-Reply-To: <20200929064218.00002422@seibercom.net> References: <20200929064218.00002422@seibercom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 29 Sep 2020 06:42:18 -0400, Jerry wrote: > I am trying to copy/move one file onto another. I need to preserve the > creation date of the target file. I see options to preserve the > creation date of the source file, but not the target file. Is it > possible? THis is possible - it's important you do not unlink (remove) the original file whose creation time you want to preserve. I'm not sure if cp does this while overwriting, but you can use shell redirection: $ cat /path/to/souce/file > /path/to/target/file Only the modification date will be altered. You can verify that using "stat filename". Note that creation time refers to the inode. Even if you re-create a file (remove, then create with the same name), you'll probably get a different inode, and therefore a different creation time. If you want to preserve modification and access time, you can do so using "cp -p"; to alter them after creation, use "touch -m" and "touch -a" respectively. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200929134051.b17c0b48.freebsd>