On Sat 16 May 2026 at 14:06:57 (-0400), [email protected] wrote:
> I tend to avoid the use of find (1) because I never really "internalized" the 
> syntax) and (2) on the assumption that it hits the disk "harder" than locate. 
>  
> 
> I mean, updatedb runs once a day (on my systems) and I assume (I know) that 
> its database is mostly cached somewhere, but I don't really know how it finds 
> new files.
> 
> Is there any validity to the idea that find is harder on disks (hits them 
> more 
> often / more widely) than locate?

No idea.  When I unmount storage devices, I run locate to index them,
but also generate a ls-lR.gz, and a compressed sorted listing of all
the files (full-time, size, path) and their directories.
(It's a bit slow generating all that for a large NTFS volume.)

Of these three indexes, I use the locate .db the least, and most
frequently zgrep the listing. Generating all three archive files
is for my convenience, not the hardware's.

As for the complexities of find, that's easy to deal with. Write them
into bash functions when complicated (I've just posted one), and also
keep one-liners in your command recall buffer. So, for example, I can
type "find" and press ↑ several times to recall a command like:

  find . -type f -mmin -1440 -printf '%Ta%TH:%TM:%.5TS%11s  %P\n' | sort -n -k 
2 | less # one day by size

That's useful when your browser or some fancy GUI thingy saves a
file and you don't have a clue where it went. (If that just happened,
I would line-edit the 1440 to 10, 2 to 3, and . to relevant high-level
directories, and get a listing by name of all the files modified
in the last ten minutes. The default is documented by the comment.)

I have a battery of such command lines, and I can modify them after
recalling them, to fit the task in hand. eg:

  find ~/scores/ ~/Lilylib/ \( -name \*.ly -o -name \*.ily -o -name \*.lily \) 
-exec grep -H -i 'x' {} \; | sort | less # display lines

and that one has a companion to display matching files rather than
just the matching lines:

  less $(find ~/scores/ ~/Lilylib/ \( -name \*.ly -o -name \*.ily -o -name 
\*.lily \) -print | sort | while read j; do grep -l -i -e 'x' "$j"; done) # 
display files

Cheers,
David.

Reply via email to