2
1
Follow-on to Spotlight and the locate command don't search *all* folders:
The steps mentioned by Gordon Davisson were performed; .bashrc
was entered in the Spotlight search field, and System and Invisible files were enabled as per the above reference. The .bashrc
file didn't show up at all. The ${HOME}
perm's were changed from 750
to 755
and several hours elapsed, but .bashrc
still did not show up.
What is required to see .bashrc
with Spotlight? How can Spotlight display .bashrc
everywhere, if at all, to see the most recentt one, as in?:
me@My-MacBook-Pro ~
$ locate .bashrc | most_recent_file
/Users/me/.bashrc
(most_recent_file
is a Perl script which stat's each file in a list and prints the name of the newest one):
Note: The locate.updatedb
database creation script was changed to allow find to search the /etc/locate.rc
specified volume(s) as root
or nobody
, depending on whether root
or daemon
invokes it, as per What folders are indexed / covered by 'locate'). The logic is tricky, so here's the comment for the updated /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
Here is the Perl source for the most_recent_file.pl
script. We have a symbolic link most_recent_file
in our search paths.
#!/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;
}
2Doesn't seem to work on macOS Sierra (10.12) anymore. – Norswap – 2017-01-06T21:51:32.047
I changed the Finder attribute AppleShowAllFiles to true. I also set the spotlight Kind attribute File visibility to Visible or invisible. Neither of these yield a visible invisible file from spotlight like .bashrc. – Billy McCloskey – 2013-12-27T01:25:37.037