Friday, May 1, 2015

BASH copy preserving timestamps in Linux and OSX

The cp command annoys me sometimes in that i expect my files to retain their time-stamps.  However, such is not the default.  To set this behavior automatically, aliases may be used.

In a Linux ~/.bashrc file, include the follwing alias:
alias cp="cp --preserve=timestamps"

In an OSX ~/.bash_profile, include the following alias:
alias cp="cp -p"

In both cases you will need to exit and restart bash.


No comments:

Post a Comment

Comments, Suggestions or "Thank you's" Invited!