用戶不時上載帶有標記「com.apple.quarantine」的文件。當用戶從互聯網上下載文件到他的電腦時,我認爲這是增加的。從Linux上的文件中刪除com.apple.quarantine
我的問題是,如果我在Linux上如何從文件中刪除它?
謝謝
用戶不時上載帶有標記「com.apple.quarantine」的文件。當用戶從互聯網上下載文件到他的電腦時,我認爲這是增加的。從Linux上的文件中刪除com.apple.quarantine
我的問題是,如果我在Linux上如何從文件中刪除它?
謝謝
使用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"
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目錄下的文件。