[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SLUG] howto copy files and keep details intact?



> I have a directory of files (ip accounting data) that I want to move to 
> another directory.  If possible, how can I do this while keeping the 
> creation date etc the same?


$ cd /yourdir
$ find . -print | cpio -pdmuv /newdir

$ man cpio

   {-p| --pass-through}
   In copy-pass mode, cpio copies files from one directory
   tree to another, combining the copy-out and copy-in steps
   without actually using an archive. It reads the list of
   files to copy from the standard input; the directory into
   which it will copy them is given as a non-option argument.

   -d, --make-directories
   Create leading directories where needed.

   -m, --preserve-modification-time
   Retain previous file modification times when creating files.

   -u, --unconditional
   Replace  all  files, without asking whether to replace
   existing newer files with older files.

   -v, --verbose

"find" has a whole bunch of options for selecting files based
on all sorts of characteristics, eg -newer -type. But you don't
have to use find, the list of files to be copied comes from
standard input so you can use whatever tools you like to
generate the listing.

Here's a neat trick to find out what's using up all your space

$ du -ax | sort -rn | less

HTH

Pete







-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug