upvote
I think I would do it more like:

  find /bin/ /usr/bin/ /sbin/ /usr/sbin/ -executable -type f -exec whatis "$(basename {})" \; | sort -u > commands.txt
reply
You would need to make those double-quotes into single-quotes. Double-quotes will interpolate the $() immediately, running basename before find runs. Single-quotes will not interpolate the $(), so the whole string gets passed to find for it to execute each time
reply
It worked when I tried it. Upon investigation, this is because `basename {}` returns `{}`, which is interpolated; thus the exec just uses the full file paths; but as it turns out, `whatis` works fine with those paths.

It won't work with single quotes because `find` won't do that interpolation when it processes the `-exec` arguments; `whatis` ends up receiving a string with a literal dollar sign etc.

I think the kind of interpolation I originally had in mind isn't possible with `find`. Thankfully it apparently isn't needed (at least with my local `whatis`).

reply
I think looking at some of the documentation for oils (née oil sh) and ysh - as well as [looking at using] these two projects [in place of bash] - is also a good idea today:

https://oils.pub/

reply