2016-12-07 35 views
2

在bash模糊匹配的命令,當我輸入如何找到在bash

icc 

我得到

No command 'icc' found, but there are 27 similar ones 

如何找到這27個類似的命令?

+2

https://askubuntu.com/questions/197633/any-way-to-list-similar-commands – melpomene

+1

@sat看起來不都有關。 – melpomene

+0

基於通常用於拼寫檢查的編輯距離。 – jasonz

回答

1

最大限制爲15,您可以暫時將其更改爲如下所示;

找到CommandNotFound.py

sudo find/-name "CommandNotFound.py" 

打開此文件,以root權限;

sudo gedit /usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py 

更改max_len 15至150;

def print_spelling_suggestion(self, word, min_len=3, max_len=150): 

或更改如下;

... 
#if len(possible_alternatives) > max_len: 
# print(_("No command '%s' found, but there are %s similar ones") % (word, len(possible_alternatives)), file=sys.stderr) 
#elif len(possible_alternatives) > 0: 
if len(possible_alternatives) > 0: 
      print(_("No command '%s' found, did you mean:") % word, file=sys.stderr) 
      for (w, p, c) in possible_alternatives: 
       print(_(" Command '%s' from package '%s' (%s)") % (w, p, c), file=sys.stderr) 
... 

測試

$ icc 
No command 'icc' found, did you mean: 
Command 'hcc' from package 'uhexen2' (multiverse) 
Command 'hcc' from package 'lam4-dev' (universe) 
Command 'kcc' from package 'kcc' (universe) 
Command 'fcc' from package 'fcc' (universe) 
Command 'ico' from package 'x11-apps' (main) 
Command 'zcc' from package 'z88dk-bin' (universe) 
Command 'gcc' from package 'gcc' (main) 
Command 'cc' from package 'clang-3.4' (universe) 
Command 'cc' from package 'clang-3.5' (universe) 
Command 'cc' from package 'tcc' (universe) 
Command 'cc' from package 'clang-3.3' (universe) 
Command 'cc' from package 'gcc' (main) 
Command 'ecc' from package 'ecere-dev' (universe) 
Command 'rcc' from package 'qtchooser' (main) 
Command 'iac' from package 'libpolyorb2-dev' (universe) 
Command 'xicc' from package 'xicc' (universe) 
Command 'inc' from package 'nmh' (universe) 
Command 'inc' from package 'mailutils-mh' (universe) 
Command 'tcc' from package 'tcc' (universe) 
Command 'ick' from package 'intercal' (universe) 
Command 'ucc' from package 'exult-studio' (multiverse) 
Command 'bcc' from package 'bcc' (main) 
Command 'icp' from package 'renameutils' (universe) 
Command 'ica' from package 'italc-client' (universe) 
Command 'irc' from package 'epic5' (universe) 
Command 'irc' from package 'epic4' (universe) 
Command 'irc' from package 'ircii' (universe) 
Command 'imc' from package 'italc-management-console' (universe) 
Command 'ncc' from package 'tinyos-tools' (universe) 
Command 'scc' from package 'scheme2c' (universe) 
+0

這是一個很好的答案。謝謝。 – eleanora