I am trying to copy extended attributes from one file to another using the OSX utility "xattr". The background is that we are creating a backup tool, and the files / structure should preserve all attributes, ACLs, etc. Everything works fine except for large attributes such as resource forks. Small attributes work fine using the method below. Trying this on OS X 10.7.5 Here is what I am doing:
First, I identify the attributes in the file with "ls -l @". The result is below:
-rwxrwxrwx@ 1 testuser staff 0 3 Jan 2011 File com.apple.FinderInfo 32 com.apple.ResourceFork 237246
Now I export the attribute (com.apple.ResourceFork is the one that causes the problems):
xattr -px com.apple.ResourceFork File > attribfile
Now I want to apply this attribute to a copy of the file on another mac with this command:
xattr -wx com.apple.ResourceFork "`cat attribfile`" File
This leads to:
-bash: /usr/bin/xattr: Argument list too long
I think I know why this happens ... the fork resource data is too long to fit into the argument. I have not set a threshold at which it starts to break, but I suspect that this is due to ARG_MAX. xargs does not help here, since it is not a few smaller arguments, but one very large one.
So many questions:
- Is there a way to get xattr to accept this big deal? How to connect it through a standard input? The man page does not show it, but I am not an expert and there may be some creative way to do this.
- Can someone tell me the correct way to apply a large extended attribute using command line tools using command line tools?
- If there are no command line tools, any recommendations for third-party tools?
Chris source share