PROBLEM: cp --attributes-only Source Target results in two files unchanged, where the attributes from Source should be copied to Target.

Attempts to solve: As I have the 8.13 version of coreutils installed [Aha?], I wonder why this option is mentioned, but doesn't seem to work. No error messages, no nothing, even when running it with --verbose. The same goes when trying to copy the attributes from various accounts. Nothing.

In cp's man page I found the option

--attributes-only -> don't copy the file data, just the attributes

In this answer I found that

With recent versions of GNU coreutils (≥ 8.6), you can use cp --attributes-only to replicate the metadata … of a file on another file without changing the target file's contents.

In another posting, someone mentions to be working in Ubuntu, but then there are remarks that I doesn't work on Mac OS X.

QUESTION: Where am I wrong? Could it be the older version of coreutils - and if so, why is there something documented that doesn't work »now«?

1 Answer 1


The info docs (accessed by running info cp or online) have the clue

     Copy only the specified attributes of the source file to the
     destination.  If the destination already exists, do not alter its
     contents.  See the `--preserve' option for controlling which
     attributes to copy.

So try adding --preserve, --preserve=context, --preserve=all, --archive, or similar, depending on which attributes you want to copy.

cp --preserve --attributes-only... works for me with coreutils 8.20.

  • Oh… I didn't see the connection :)
    – erch
    Oct 7, 2013 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .