执行了 Gordon Davisson 提到的步骤;.bashrc
在 Spotlight 搜索字段中输入了 ,并根据上述参考启用了系统和不可见文件。.bashrc
文件根本没有出现。${HOME}
权限从 更改为750
,755
几个小时过去了,但.bashrc
仍然没有出现。
使用 Spotlight需要什么.bashrc
?Spotlight 如何才能.bashrc
在所有地方显示(如果有的话),以便查看最新的一个,例如:
me@My-MacBook-Pro ~
$ locate .bashrc | most_recent_file
/Users/me/.bashrc
(most_recent_file
是一个 Perl 脚本,它统计列表中的每个文件并打印最新文件的名称):
注意:locate.updatedb
数据库创建脚本已更改为允许 find 搜索/etc/locate.rc
指定的卷作为root
或nobody
,具体取决于 或 是否root
调用daemon
它,如哪些文件夹被“定位”索引/覆盖)。逻辑很棘手,因此这里是更新后的注释/usr/libexec/locate.updatedb
:
# Modify test for expected invocations by either daemon (id=1) or root (id=0);
# if invoked as root, skip test section and search filesystems as root as per
# /etc/locate.rc, a possible security risk if /etc/locate.rc is not tailored
# for production use. Invoked as daemon, we "spawn" ourselves as nobody to
# gain nobody's filesystem visability, rather than daemon's.
#if [ "$(id -u)" = "0" ]; then
if [ "$(id -u)" = "1" ]; then
这是脚本的 Perl 源代码。我们的搜索路径中most_recent_file.pl
有一个符号链接。most_recent_file
#!/usr/bin/perl -wnl
# From pathname inputs, emits name of one most recently modified
# Gives correct answer where pipelines of this form may not:
# find . -print | xargs ls –lrdt | tail -1
# NOTE: Use find or locate to provide input, or ls -d dir/*,
# but *not* simply "ls dir" (dir won't be present in pathname)
# Sample invocations:
# locate '*.c' | most_recent_file
# ls -d /etc/* | most_recent_file
# find /local -name 'somescript' | most_recent_file
# most_recent_file < filelist
BEGIN {
$newest = 0; # initialize modification-time reference point
$name = "";
}
# Get file's numeric modification time; 10th value from stat
$mtime = ( stat $_ )[9]; # indexing into output of stat
if ( $mtime > $newest ) { # if True, current file is newest yet seen
# Remember mod-time for comparison to others,
# and remember filename for final report
$newest = $mtime;
$name = $_;
}
END {
print $name;
}
答案1
我也没能使 Finder 的聚光灯搜索列出 .bashrc(也许它找到了它,但因为不可见而没有显示?)。但是聚光灯的命令行界面……好吧,可以让它显示它。这有效:
$ mdfind kMDItemFSName = ".bashrc"
/Users/gordon/.bashrc
但由于某种原因,该-name
选项没有显示:
$ mdfind -name ".bashrc"
$
...所以我不完全相信它能找到我认为应该找到的东西。