Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I copy, recursive directory, only files with a attribute 1, and reset this a attribute to 0? Thanks, Francisco

share|improve this question
You will have to specify what you mean by "attribute 1" – psusi Jun 6 '12 at 0:55

You will probably have to install the package attr if you want to set and get extended attributes.

You can write a script in a shell language, or a higher level language to descend directories and examine each file, copying the ones that meet your criteria. I would use python, personally.

By using the getfattr command you can retrieve the value for a you define yourself as an extended attribute. After copying the file you could then set a different value by executing the setfattr command.

I don't see an option for rsync or dump to do this. Dump is said to ignore files with the d (non-extended) attribute set. These regular attributes are set with chattr and attributes are examined with lsattr. These commands also include setting a version for a file, in case that can be used as a substitute for the bit setting/clearing you are asking about. I suppose you could make the version alternate between 0 and 1 if you like. See man chattr and man lsattr and, in particular, the -v option.

The legacy dump command appears to use a file (/var/lib/dumpdates) of its own to keep track of what has been backed-up when so it can backup incrementally, which may be the sort of thing you are getting at.

It may be helpful to know more about what you are trying to achieve in case there is another approach that doesn't involve programming.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.