0

I will ask my question starting from a real example.

From the command line prompt, I want to search for a command line tool that will output information about my smart card.

Side Note: I already know that the command line tool that I am looking for is the system_profiler SPSmartCardsDataType but let's pretend I do not know yet.

Step #1 From the command line prompt I type the following: apropos smart card

Step #2 I receive the following result:

SmartCardServices(7)     - overview of SmartCard support
SmartCardServices-legacy(7) - overview of legacy SmartCard support
com.apple.ifdreader(8)   - SmartCard reader daemon
ctkahp(8)                - SmartCard Agent
ctkbind(8)               - SmartCard pairing tool
ctkd(8)                  - SmartCard daemon/agent
pam_smartcard(8)         - Smartcard PAM module
ssh-keychain(8), ssh-keychain.dylib(8) - smartcard/keychain support library

And of course I can use the SmartCardServices command line tool but this is not what I am looking for.

Question: How can I make a better search for a specific command line tool? I guess a search that will query the command line options too?

In my specific case if I search for the keyword smart card why the output does not show me at least the term system_profiler?

I hope I was clear, if not let me know and I can rephrase my question. Once again, the above it is just an example, I use SmartCard because this is what I had issue in searching today, but it can be anything else.

  • Smart Card services is something that is "more uniquely" Apple than it is general Unix so apropos may not be "up-to-date" so to speak with respect to CLI tools. You'd probably want to start with the Official Apple Documentation and go from there. – Allan Aug 31 '20 at 23:13
2

apropos just looks in the command description, not the full man page. There are no specific commands to "intelligently" search within all man pages, but in a bind you can always run

cd /usr/share/man
zgrep -i smartcard man*/*

PS: This won't help for system_profiler though because the data types supported aren't listed in the man page at all.

1

How can I make a better search for a specific command line tool? I guess a search that will query the command line options too?

The problem with this type of question is qualifying what constitutes “a better search.” It could be accuracy or frequency. Put another way, it would be somewhere on the line that balances quantity and quality of results.

That said, there’s only so much you’re going to get from the serarch. From the apropos man page:

Search the whatis database for strings.

The whatis database is nothing more than a database of short descriptions of system commands. It’s not a large, complex, rational database filled with metadata for each command; it is what it is.

Using your example of “smart card,” you’re getting the results that you are because those are the commands where “smart card” shows up in the command descriptions database.

So, to get better results, you would want to be flexible with your keywords and use synonyms for the terms you’re searching for. That said....

You can output the contents of the whatis database with this command

whatis ' ' | egrep '\(1\)'|sort

That’s it. There’s not too much to it. apropos will search this matching keywords. If those keywords aren’t in the database, you wont get hits.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .