I want to search for bash commands in the bash itself. When I forget the name of a command I want a fast way to find it. For example "search for file" should suggest "find".
Asked
Active
Viewed 181 times
2 Answers
4
The closest thing you can get is via one of these commands:
man -k search
apropos search
These will return all manpages whose description contains the word "search".
You can restrict the search to pages in section 1 (user commands) and 8 (admin commands) with the (non-standard) -s
option:
man -ks1,8 search
That would omit pages about programming APIs or concepts, file formats...

Stéphane Chazelas
- 544,893

dr_
- 29,602
-
Thanks for your answer! My Problem with this is that there is no man page for "find". – questionanswer Jan 09 '18 at 10:03
-
Which Linux distro are you using? There should be a manpage for
find
on all modern distros. – dr_ Jan 09 '18 at 10:28 -
Termux on Android which uses bash. There are man pages for other commands (e.g. "ssh"..). – questionanswer Jan 09 '18 at 10:35
1
As @dr_ suggested using man -k search
works well, but sometimes it gives a long list of results along with the description. So, if you want to display results nicely you can use cut
and list only the name of commands as follows
Let say we want to find *mod (usermod
, groupmod
, depmod
)
man -k mod | cut -d ' ' -f 1 | grep 'mod$'

Abdullah
- 11
-
man -k mod | awk '$1 ~ /mod$/'
(or justman -k 'mod$'
) would probably be more useful (if only because many of those will be about things other than commands). See alsotype -m '*mod'
inzsh
orcomgen -c | grep 'mod$'
in bash. Alsoman -s1,6,8 -k 'mod$'
to restrict the search to sections 1, 6 and 8 (at least with theman
from mandb) – Stéphane Chazelas Jan 15 '22 at 08:43 -
@StéphaneChazelas you are right. Your suggestions also worked well except
comgen -c | grep 'mod$'
. (comgen: command not found) Do you think it comes builtin or do we have to install it? – Abdullah Jan 15 '22 at 16:08 -
elinks 'g:linux search for file'
? – Stéphane Chazelas Jan 09 '18 at 15:21