2014-04-05 228 views

回答

2

使用setfattr。在linux上,擴展屬性應該在「用戶」中。命名空間(您的里程可能會有所不同):

setfattr -x 'user.com.apple.quarantine' file1 [ file2 [ ... ] ] 

不幸的是,-xattr謂語並沒有使它成爲GNU找到卻又如此處理一個完整的層次涉及暴力,和無知的做法看起來像這樣:

cd /path/to/search 

errors=/var/tmp/setfattr.errors 

find . -exec setfattr -x 'user.com.apple.quarantine' {} + 2> "$errors" 

這之後,$錯誤文件應只包含文件,這並沒有相關的屬性條目:

grep -v 'No such attribute' -- "$errors" 
-1
touch /tmp/com.apple.quarantine.test1 
touch /tmp/com.apple.quarantine.test2 

然後運行以下代碼。

for f in $(find /tmp/ -type f|grep -i 'com.apple.quarantine'); 
do 
     OLD_NAME=$(echo $f|awk -F "/" '{print $NF'}) 
     NEW_NAME=$(echo $OLD_NAME|sed "s/com\.apple\.quarantine\.//g") 
     echo $NEW_NAME 
     DIR_NAME=$(dirname $f) 
     cd $DIR_NAME 
     mv "$OLD_NAME" "$NEW_NAME" 
done 

現在只有test1的TEST2在/ tmp目錄下的文件。