<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Don&#039;t Panic &#187; cp</title>
	<atom:link href="http://danielfree.net/archives/tag/cp/feed" rel="self" type="application/rss+xml" />
	<link>http://danielfree.net</link>
	<description>时间足够你爱</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:45:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>mac下文件带有扩展属性的问题</title>
		<link>http://danielfree.net/archives/10?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=10</link>
		<comments>http://danielfree.net/archives/10#comments</comments>
		<pubDate>Thu, 16 Jul 2009 22:15:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[术业]]></category>
		<category><![CDATA[cp]]></category>
		<category><![CDATA[file extended attribute]]></category>
		<category><![CDATA[mac os]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://daniel.codetea.co.uk/?p=10</guid>
		<description><![CDATA[在mac os下HFS+的文件系统上 文件经常会被附加上mac专有的扩展属性 具体的表现是用ls -l 查看时 会有@标志 比如 $ ls -l total 0 -rw-r&#8211;r&#8211;@ 1 Daniel  staff  0 16 Jul 19:28 1.txt -rw-r&#8211;r&#8211;  1 Daniel  staff  0 16 Jul 19:28 2.txt 这个属性是用户在Finder里对文件进行任意操作时 就会附加上的 -  -  比如右键看Info 然后在Spotlight Commends里写上几个字再删掉  @属性是不会删掉的 问题来了 &#8211; 如果把文件从mac系统用tar打包 拷贝到linux系统释放文件  @属性会造成莫名的错误 我就在我们公司的linux服务器上发布网站的时候碰到过这个事情  页面里莫名出现一段com.apple.metadata *** 这样的字段 google了一阵 原因在于tar命令本身默认并不区分extend attributes 但是mac下的cp命令做的更好 选项 -X 即可忽略这些属性 [...]]]></description>
			<content:encoded><![CDATA[<p>在mac os下HFS+的文件系统上 文件经常会被附加上mac专有的扩展属性 具体的表现是用ls -l 查看时 会有@标志 比如</p>
<p>$ ls -l<br />
total 0<br />
-rw-r&#8211;r&#8211;@ 1 Daniel  staff  0 16 Jul 19:28 1.txt<br />
-rw-r&#8211;r&#8211;  1 Daniel  staff  0 16 Jul 19:28 2.txt</p>
<p>这个属性是用户在Finder里对文件进行任意操作时 就会附加上的 -  -  比如右键看Info 然后在Spotlight Commends里写上几个字再删掉  @属性是不会删掉的</p>
<p>问题来了 &#8211; 如果把文件从mac系统用tar打包 拷贝到linux系统释放文件  @属性会造成莫名的错误</p>
<p>我就在我们公司的linux服务器上发布网站的时候碰到过这个事情  页面里莫名出现一段com.apple.metadata *** 这样的字段</p>
<p>google了一阵 原因在于tar命令本身默认并不区分extend attributes 但是mac下的cp命令做的更好 选项 -X 即可忽略这些属性</p>
<p>man cp:   -X    Do not copy Extended Attributes (EAs) or resource forks.</p>
<p>对于这个问题 nabble上的<a href="http://www.nabble.com/Re:-Mac-OS-X-10.5-._-and-.DS_Store-files:-cp--XR-%28before-tar%29-to-lose-Extended-Attributes-%28EAs%29-and-resource-forks-p13775685s6745.html" target="_blank">这个帖子</a>有着很精简的回答  即在打包前先用cp -XR 拷贝出一份没有扩展属性的 然后再tar</p>
<p>对于大量文件传输来说这是最简单的办法</p>
<p>如果想手动去除掉文件的@属性 可以使用命令 xattr</p>
<p>$ xattr -l 1.txt<br />
com.apple.metadata:kMDItemFinderComment:<br />
0000   62 70 6C 69 73 74 30 30 50 08 00 00 00 00 00 00    bplist00P&#8230;&#8230;.<br />
0010   01 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00    &#8230;&#8230;&#8230;&#8230;&#8230;.<br />
0020   00 00 00 00 00 00 00 00 00 09                      &#8230;&#8230;&#8230;.</p>
<p>$ xattr -d com.apple.metadata:kMDItemFinderComment 1.txt<br />
$ xattr -l 1.txt<br />
$<br />
此时就没有特殊属性了</p>
]]></content:encoded>
			<wfw:commentRss>http://danielfree.net/archives/10/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: danielfree.net @ 2012-05-22 18:28:55 by W3 Total Cache -->
