Mac Linux 文件权限-rw-r--r--后面有个@

mac里面查看文件时,无意中发现有的权限后面带了一个"@"。
在这里插入图片描述
好奇心很强的我必须知道那是啥玩意。
在这个帖子里"ls" on Mac and extended file attributes找到了答案,实际上人家标题就说明了,这是mac的拓展文件属性。
这里就引申出来一个指令"xattr",man一下可以看到详细的描述。

XATTR(1)                  BSD General Commands Manual                 XATTR(1)

NAME
     xattr -- display and manipulate extended attributes

SYNOPSIS
     xattr [-lrsvx] file ...
     xattr -p [-lrsvx] attr_name file ...
     xattr -w [-rsx] attr_name attr_value file ...
     xattr -d [-rsv] attr_name file ...
     xattr -c [-rsv] file ...
     xattr -h | --help

DESCRIPTION
     The xattr command can be used to display, modify or remove the extended attributes of one or more files, including directories and symbolic links.  Extended attributes are arbitrary metadata stored with a file, but separate from the
     filesystem attributes (such as modification time or file size).  The metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data.

使用xattr可以处理拓展属性,比如我这儿整一个普通文件:

ls -l text.txt
-rwxr-xr-x  1 jan  staff  1592  1 20 09:37 text.txt

finder里面:
在这里插入图片描述
这里加了个标签,再去看看。

ls -l@ text.txt
-rwxr-xr-x@ 1 jan  staff  1592  1 20 09:37 text.txt
	com.apple.FinderInfo	  32
	com.apple.metadata:_kMDItemUserTags	  53

现在就变成了带拓展属性的文件了。
题外话,据说有人遇到tar打包此类文件到别的环境处理出错,那么需要删除他们。

xattr -d  com.apple.FinderInfo  text.txt

ls -l@ text.txt
-rwxr-xr-x@ 1 jan  staff  1592  1 20 09:37 text.txt
	com.apple.metadata:_kMDItemUserTags	  53

可以看到com.apple.FinderInfo已经被删除了。

xattr -d    com.apple.metadata:_kMDItemUserTags text.txt
ls -l@ text.txt
-rwxr-xr-x  1 jan  staff  1592  1 20 09:37 text.txt

已经完全变成了正常的文件
当然,仔细看了man的人就会发现-c指令,移出所有拓展属性。

xattr -c text.txt
ls -l@ text.txt
-rwxr-xr-x  1 jan  staff  1592  1 20 09:37 text.txt

好了,就这么多,简单记录,估计也用不了几回。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值