如何查询所有Finder别名的目标?
Mac OSX 10.6
我有一些别名指向错误的卷。我想在我的整个层次结构中搜索此类别名。它们是别名,而不是符号链接,所以我不能只做find / -type l -ls | grep badVolumeName
.
别名似乎有一个 com.apple.ResourceFork,但是使用 xattr
查询它会得到二进制数据。有没有办法将别名的目标转储为文本,以便我可以 grep 查找错误的卷名称?或者还有什么其他方法可以做到这一点?
Mac OSX 10.6
I've got some aliases that are pointing to the wrong volume. I'd like to search my whole hierarchy for such aliases. They're aliases, not symlinks, so I can't just do find / -type l -ls | grep badVolumeName
.
It seems that aliases have a com.apple.ResourceFork, but querying this with xattr
gives me binary data. Is there a way to dump the target of the alias as text so I can grep for the bad volume name? Or what's another way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要查找别名文件,您可以使用StackOverflow 上的此答案。首先,创建一个脚本
is_alias.sh
:然后运行
获取别名的路径似乎相当困难。
有人发布了使用 MacPerl 的解决方案,但我没有MacPerl 我没有测试过这个,不知道它是否有效。
AskDifferent 上有一个类似的问题,有几个不同的建议,但似乎都没有真正解决问题。 Applescript 的答案是好的,但是获取别名文件的“原始项目”这一关键操作似乎不适用于损坏的别名。
您还可以查看这个问题,其中可能有一些Cocoa解决方案。
To find alias files you can make use of this answer on StackOverflow. First, create a script
is_alias.sh
:and then run
Getting the path of an alias seems quite difficult.
Someone has posted a solution using MacPerl, but as I do not have MacPerl I haven't tested this and don't know whether it works.
There is a similar question on AskDifferent, with several different suggestions, but none of them seem to actually solve the problem. The Applescript answer is okay, but the key operation, getting the "original item" of an alias file, doesn't seem to work for broken aliases.
You can also take a look at this question which might have some Cocoa solutions.
bash 脚本对我不起作用,因为我在 zsh 中运行它。所以我用 find: 运行了下面的 perl 脚本
,这是 perl 脚本:
the bash script didn't work for me because I was running it in zsh. so I ran the below perl script with find:
and here's the perl script: