Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 5058  / 3 Years ago, fri, july 16, 2021, 6:27:51

When you write the command name wrong, bash often does this:



septi@norbert:~$ good
No command 'good' found, did you mean:
Command 'gold' from package 'binutils' (main)
Command 'gmod' from package 'gmod' (universe)
Command 'goo' from package 'goo' (universe)
Command 'god' from package 'god' (universe)
Command 'geod' from package 'proj-bin' (universe)
Command 'gord' from package 'scotch' (universe)
good: command not found


Or sometimes it does this:



septi@norbert:~$ nftp
No command 'nftp' found, but there are 23 similar ones
nftp: command not found


Is there any way to ask bash to show these 23 similar commands for me? And, is there a way to show similar commands, including those that aren't yet installed, instead of running the application, ftp for example?


More From » bash

 Answers
4

Bash uses the command /usr/lib/command-not-found for looking similar commands. This in turn uses Python's CommandNotFound module.



The output you see on the terminal(stderr in this case), is also generated from this module. The location of this module is /usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py, on Ubuntu 14.04 and up. There is a default limit set on number of similar commands in the function CommandNotFound.print_spelling_suggestion(self, word, min_len=3, max_len=15) on line 138. You can modify the max_len value to say 30 (Use sudo nano or gksudo gedit to edit this file).


[#35090] Sunday, July 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
enefiama

Total Points: 43
Total Questions: 125
Total Answers: 102

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
enefiama questions
;