How to clone/copy all file/directory attributes onto different file/directory?

Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself.
This does not work:
cp -v --attributes-only A B
cp: omitting directory `A'
Note: It does not have to be cp.
filesystems backup file-copy xattr
add a comment |Â
up vote
11
down vote
favorite
I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself.
This does not work:
cp -v --attributes-only A B
cp: omitting directory `A'
Note: It does not have to be cp.
filesystems backup file-copy xattr
1
You did not pass-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note thatinstallcan preserve SELinux contexts.
â lynxlynxlynx
Jul 29 '12 at 20:03
3
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
1
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
1
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55
add a comment |Â
up vote
11
down vote
favorite
up vote
11
down vote
favorite
I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself.
This does not work:
cp -v --attributes-only A B
cp: omitting directory `A'
Note: It does not have to be cp.
filesystems backup file-copy xattr
I want to copy the attributes (ownership, group, ACL, extended attributes, etc.) of one directory to another but not the directory contents itself.
This does not work:
cp -v --attributes-only A B
cp: omitting directory `A'
Note: It does not have to be cp.
filesystems backup file-copy xattr
filesystems backup file-copy xattr
edited Jul 31 '12 at 22:05
bahamat
23.7k14590
23.7k14590
asked Jul 29 '12 at 18:14
Grzegorz Wierzowiecki
5,0431260101
5,0431260101
1
You did not pass-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note thatinstallcan preserve SELinux contexts.
â lynxlynxlynx
Jul 29 '12 at 20:03
3
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
1
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
1
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55
add a comment |Â
1
You did not pass-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note thatinstallcan preserve SELinux contexts.
â lynxlynxlynx
Jul 29 '12 at 20:03
3
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
1
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
1
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55
1
1
You did not pass
-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note that install can preserve SELinux contexts.â lynxlynxlynx
Jul 29 '12 at 20:03
You did not pass
-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note that install can preserve SELinux contexts.â lynxlynxlynx
Jul 29 '12 at 20:03
3
3
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
1
1
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
1
1
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55
add a comment |Â
5 Answers
5
active
oldest
votes
up vote
12
down vote
accepted
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of theUSAGEsection of thersync(1)man page.
â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would bersync -a -AX --include='*/' --exclude='*'. I haven't tested.
â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
 |Â
show 1 more comment
up vote
0
down vote
chmod --reference=first-dir second-dir
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.
â ShadSterling
Oct 6 '16 at 12:51
add a comment |Â
up vote
0
down vote
cp -rfp from_dir to_dir
-r- recursive-f- force-p- preserve attributes: mode, ownership, timestamps
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
add a comment |Â
up vote
0
down vote
I do not understand because it seems to work for others, but the rsync method fails for me on FreeBSD with ZFS. Nothing happens. However Jean-François DockesâÂÂs method works. (see: https://www.lesbonscomptes.com/pxattr/ ) Source directory = A & destination directory = B, from the original question.
pxattr -lR A > tmp.EAs
(edit the first line of tmp.EAs to change the A directory to B, s/A/B/)
pxattr -S tmp.EAs
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
-3
down vote
You need the "-r" for copying a directory.
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-rimplies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.
â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
add a comment |Â
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
12
down vote
accepted
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of theUSAGEsection of thersync(1)man page.
â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would bersync -a -AX --include='*/' --exclude='*'. I haven't tested.
â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
 |Â
show 1 more comment
up vote
12
down vote
accepted
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of theUSAGEsection of thersync(1)man page.
â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would bersync -a -AX --include='*/' --exclude='*'. I haven't tested.
â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
 |Â
show 1 more comment
up vote
12
down vote
accepted
up vote
12
down vote
accepted
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
edited Jul 31 '12 at 18:45
jw013
35.2k698123
35.2k698123
answered Jul 31 '12 at 16:20
killermist
939922
939922
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of theUSAGEsection of thersync(1)man page.
â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would bersync -a -AX --include='*/' --exclude='*'. I haven't tested.
â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
 |Â
show 1 more comment
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of theUSAGEsection of thersync(1)man page.
â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would bersync -a -AX --include='*/' --exclude='*'. I haven't tested.
â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
That last edit is definitely a hit there. With or without a / on the second-dir, that finally does exactly what is asked, it looks like.
â killermist
Jul 31 '12 at 18:50
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of the
USAGE section of the rsync(1) man page.â jw013
Jul 31 '12 at 18:51
The trailing slash only makes a difference on the first argument, not the second. It's explained in the 3rd or 4th paragraph of the
USAGE section of the rsync(1) man page.â jw013
Jul 31 '12 at 18:51
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
@jw013 After reading the rsync documentation repeatedly, months ago, my conclusion was that the trailing slashes were an implied "into", whether in the first (second, third, etc) or last argument. But then again, I often end my commands with a / on the last argument to imply/demand an "into" affect.
â killermist
Jul 31 '12 at 18:58
My gut feeling to copy all directory attributes and no regular file would be
rsync -a -AX --include='*/' --exclude='*'. I haven't tested.â Gilles
Jul 31 '12 at 19:11
My gut feeling to copy all directory attributes and no regular file would be
rsync -a -AX --include='*/' --exclude='*'. I haven't tested.â Gilles
Jul 31 '12 at 19:11
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
@jw013 Thanks on helping get this answer dialed in. I tried SO many options on my little sandbox test environment, and kept coming close, but having some part of it not work right.
â killermist
Aug 1 '12 at 17:04
 |Â
show 1 more comment
up vote
0
down vote
chmod --reference=first-dir second-dir
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.
â ShadSterling
Oct 6 '16 at 12:51
add a comment |Â
up vote
0
down vote
chmod --reference=first-dir second-dir
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.
â ShadSterling
Oct 6 '16 at 12:51
add a comment |Â
up vote
0
down vote
up vote
0
down vote
chmod --reference=first-dir second-dir
chmod --reference=first-dir second-dir
answered Nov 29 '12 at 15:23
Etienne Dublé
11
11
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.
â ShadSterling
Oct 6 '16 at 12:51
add a comment |Â
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.
â ShadSterling
Oct 6 '16 at 12:51
2
2
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
This won't work recursively, and I believe it will not copy ACLs or extended attributes.
â Mat
Nov 29 '12 at 17:17
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync
--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.â ShadSterling
Oct 6 '16 at 12:51
It's not supposed to be recursive: The OP asked for "not the directory contents itself", and the accepted answer tells rsync
--no-recursive. The problem with this answer is that it doesn't do ACLs or XATTRs.â ShadSterling
Oct 6 '16 at 12:51
add a comment |Â
up vote
0
down vote
cp -rfp from_dir to_dir
-r- recursive-f- force-p- preserve attributes: mode, ownership, timestamps
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
add a comment |Â
up vote
0
down vote
cp -rfp from_dir to_dir
-r- recursive-f- force-p- preserve attributes: mode, ownership, timestamps
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
add a comment |Â
up vote
0
down vote
up vote
0
down vote
cp -rfp from_dir to_dir
-r- recursive-f- force-p- preserve attributes: mode, ownership, timestamps
cp -rfp from_dir to_dir
-r- recursive-f- force-p- preserve attributes: mode, ownership, timestamps
edited Jul 4 '14 at 13:48
slmâ¦
240k66499668
240k66499668
answered Jul 4 '14 at 13:36
burtsevyg
1112
1112
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
add a comment |Â
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
Also need --attributes-only
â smremde
Oct 14 '17 at 21:11
add a comment |Â
up vote
0
down vote
I do not understand because it seems to work for others, but the rsync method fails for me on FreeBSD with ZFS. Nothing happens. However Jean-François DockesâÂÂs method works. (see: https://www.lesbonscomptes.com/pxattr/ ) Source directory = A & destination directory = B, from the original question.
pxattr -lR A > tmp.EAs
(edit the first line of tmp.EAs to change the A directory to B, s/A/B/)
pxattr -S tmp.EAs
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
I do not understand because it seems to work for others, but the rsync method fails for me on FreeBSD with ZFS. Nothing happens. However Jean-François DockesâÂÂs method works. (see: https://www.lesbonscomptes.com/pxattr/ ) Source directory = A & destination directory = B, from the original question.
pxattr -lR A > tmp.EAs
(edit the first line of tmp.EAs to change the A directory to B, s/A/B/)
pxattr -S tmp.EAs
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I do not understand because it seems to work for others, but the rsync method fails for me on FreeBSD with ZFS. Nothing happens. However Jean-François DockesâÂÂs method works. (see: https://www.lesbonscomptes.com/pxattr/ ) Source directory = A & destination directory = B, from the original question.
pxattr -lR A > tmp.EAs
(edit the first line of tmp.EAs to change the A directory to B, s/A/B/)
pxattr -S tmp.EAs
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I do not understand because it seems to work for others, but the rsync method fails for me on FreeBSD with ZFS. Nothing happens. However Jean-François DockesâÂÂs method works. (see: https://www.lesbonscomptes.com/pxattr/ ) Source directory = A & destination directory = B, from the original question.
pxattr -lR A > tmp.EAs
(edit the first line of tmp.EAs to change the A directory to B, s/A/B/)
pxattr -S tmp.EAs
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 12 mins ago
cira
1
1
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
cira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
up vote
-3
down vote
You need the "-r" for copying a directory.
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-rimplies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.
â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
add a comment |Â
up vote
-3
down vote
You need the "-r" for copying a directory.
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-rimplies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.
â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
add a comment |Â
up vote
-3
down vote
up vote
-3
down vote
You need the "-r" for copying a directory.
You need the "-r" for copying a directory.
answered Jul 29 '12 at 19:59
tripledes
1,01779
1,01779
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-rimplies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.
â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
add a comment |Â
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-rimplies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.
â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
2
2
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
I think I misunderstood you, you don't need the contents, just the xattr. If it was for SELinux, you could use chcon referencing the original directory (A).
â tripledes
Jul 29 '12 at 20:38
-r implies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
-r implies copy of all subdirectories and files in them... I do not want to copy whole tree... I want to copy attributes for only one and only one directory - without affecting it's contents.â Grzegorz Wierzowiecki
Jul 29 '12 at 21:20
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f44253%2fhow-to-clone-copy-all-file-directory-attributes-onto-different-file-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You did not pass
-r, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note thatinstallcan preserve SELinux contexts.â lynxlynxlynx
Jul 29 '12 at 20:03
3
possible duplicate of Clone ownership and permissions from another file?
â Gilles
Jul 30 '12 at 0:22
1
@Gilles, thank you for pointing to another topic. It solves part of problem: ownership and mode. What about extended attributes?
â Grzegorz Wierzowiecki
Jul 31 '12 at 13:13
1
@GrzegorzWierzowiecki I'm afraid very few tools support extended attributes. If they're important, use killermist's rsync suggestion.
â Gilles
Jul 31 '12 at 19:08
Btw. Here are nice examples where one may see xattrs in action: GUI of Dolphin in KDE: imgur.com/oguuJNm or URL from where file was downloaded set by browsers: references: gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7 + freedesktop.org/wiki/CommonExtendedAttributes + vhanda.in/blog/2014/07/tagging-your-files
â Grzegorz Wierzowiecki
Dec 15 '17 at 22:55