On Sun, Nov 22, 1998 at 5:39PM -0500, Jameson Burt wrote: > This is analogous to the touch command that sets the timestamps of one file > like another file, > touch -r file-template file-target > > Of course, one can go through machinations like > cp -p file-template file-target > cp file-target file-template > mv file-template file-target > However, in Linux, what we imagine has often been incorporated into a command, > slickly.
You're right. :) The command you want is cpio, in pass-through mode. It's for creating and extracting from backup archives, but -p makes it do both without actually making an archive file. You also need the 'a' and 'm' options, which preserve access and modification times. cpio reads the filename(s) to use from standard input. So, echo foo | cpio -pam /bar will take the file foo and copy it to /bar, preserving its access times, permissions, and ownership. If you wanted to move an entire directory, you'd do something like: find /foo | cpio -pamdv /bar This will create a copy of the /foo directory in /bar, again preserving all file attributes. The 'd' option tells it to create directories as necessary, and the 'v' option means "verbose", so it will show you what it's doing. As always, "man cpio" explains things more thoroughly than I can. J