【发布时间】:2013-12-16 10:58:58
【问题描述】:
我在 Ubuntu bash 中遇到了一个我无法完全理解的有趣行为。 如果我将扩展文件属性添加到文件然后更改它 - 属性将从文件中删除。从我的角度来看,这是可以的。
user@user:~/tmp$ echo "aaa" > testattr
user@user:~/tmp$ setfattr --name "user.test" --value "Tested" testattr
user@user:~/tmp$ getfattr --name "user.test" testattr
# file: testattr
user.test="Tested"
user@user:~/tmp$ vi testattr
< change something in file and save it >
user@user:~/tmp$ getfattr --name "user.test" testattr
testattr: user.test: No such attribute
但是,如果我使用 bash 在文件中写入内容 - 文件属性将保留在原处。 任何人都可以解释这种行为吗?
user@user:~/tmp$ echo "aaa" > testattr
user@user:~/tmp$ setfattr --name "user.test" --value "Tested" testattr
user@user:~/tmp$ getfattr --name "user.test" testattr
# file: testattr
user.test="Tested"
user@user:~/tmp$ echo "bbb" > testattr
user@user:~/tmp$ getfattr --name "user.test" testattr
# file: testattr
user.test="Tested"
【问题讨论】: