linux文件夹d和s,linux – 删除DS_Store文件和变体?

:2e前缀似乎是不允许使用dotfiles的netatalk服务默认设置的副作用;为了避免这种情况(即将文件名作为.DS_Store等出现在服务器上),在/etc/netatalk/AppleVolumes.default中为每个共享添加选项:usedots(参见

this previous question和

netatalk documentation).

这不会消除现有的“:2e”文件或阻止新的“.”创建文件,只需使用更健全的名称创建新文件(并使它们正确隐藏).您已完成的DSDontWriteNetworkStores设置应该阻止创建新的.DS_Store文件,但不会阻止.TemporaryItems,.Trashes,._ *文件(这些是保存资源分叉和非标准元数据的AppleDouble文件)等等.我不知道有什么方法可以防止它们被创建,你只能在之后清理它们(希望它们没有任何重要的东西 – 这并不总是一个安全的假设).

我找到了一个script by Christian Imhorst来删除服务器上的各种文件.他网站上的字符编码有点乱码,所以我会在这里添加一个清理过的(稍加修改的……)版本.我在要删除的文件名列表中添加了一些内容;随意编辑杀戮清单来品尝.但是,确保你在运行之前有一个备份,因为任何包含字符“rm -rf”的脚本都应被视为具有潜在危险性.

#!/bin/bash

# Script: sauber

# Object: Cleans up your Linux file system after a

# session with AppleTalk and Finder.

# Etymologie: sauber means clean in German

# Author: originally by Christian Imhorst [http://www.datenteiler.de/what-is-2eds_store/]

# modified by Gordon Davisson

# Test number of arguments here

if (( $# < 1 )) ; then

echo >&2

echo "We need an argument here." >&2

echo "Usage: ./sauber [Directory]" >&2

echo "Example: ./sauber /home/christian" >&2

echo >&2

exit 1

elif [[ ! -d "$1" ]] ; then

echo "$1 is not a directory" >&2

exit 1

fi

find "$1" \( -iname ':2eDS_Store' \

-o -iname '.DS_Store' \

-o -iname '.AppleDouble' \

-o -iname 'Network Trash Folder' \

-o -iname 'Temporary Items' \

-o -iname ':2eTemporary Items' \

-o -iname '.Temporary Items' \

-o -iname ':2elocalized' \

-o -iname '.localized' \

-o -iname ':2e_*' \

-o -iname '._*' \) -exec rm -rf {} \;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值