I'd like to find all directories that contain both a Makefile and a file matching *.tex. The command find or locate easily finds one or the other. But how can those results be merged or intersected, to yield just the directories desired?
A useful answer generalizes to other filenames. Even better, it can merge more than two such queries.
(I don't see how to apply find's boolean operators, e.g. "and" expr1 -a expr2. Ditto for locate -A. Maybe two searches, strip the filenames and keep the paths, sort -u, into comm -12 <(cmd1) <(cmd2)?)
-execas a test;man findlists tests and actions separately and-execis under "actions" there. Your answer is a learning material to me. – Kamil Maciorowski May 29 '17 at 18:24compgenbefore. – xenoid May 29 '17 at 20:13-aconnects tests by default, you may omit it) but what I learnt from it turned out to be so powerful (custom tests like this, yay!) I decided to award it. Keep up the good work. – Kamil Maciorowski Sep 23 '17 at 07:52{}in the shell code. – Kamil Maciorowski Dec 01 '21 at 15:43