端末で何かをすると間違って入力し、意図せず何かを入力することが多いです。
簡単な例を入力すると、int
次のように表示されます。Command 'int' not found, but there are 18 similar ones.
私について話すのではありません。必要この18の同様の命令を知りたいのですが、この「類似した18個」が何であるかを知る方法はありますか?ターミナルでも他の場所でも。
ベストアンサー1
Ubuntuでこれが起こると、askubuntu.comこれはbashが/usr/lib/command-not-found
Pythonを使用するモジュールを使用していることを意味しますCommandNotFound
。
/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py
CommandNotFound.pyファイルの178行目から始まる「しかし同様のXがあります」を担当する正確な行を見ることができます。
if len(mispell_packages)+len(mispell_snaps) > max_alt:
print("", file=self.output_fd)
print(_("Command '%s' not found, but there are %s similar ones.") % (word, len(mispell_packages)), file=self.output_fd)
print("", file=self.output_fd)
self.output_fd.flush()
return
CommandNotFound.pyが同様のコマンドのリストを返すようにするスイッチ、フラグ、またはオプションがないため、これらのパッケージが何であるかを本当に知りたい場合は、Pythonファイルのこの部分を編集して2行を追加して印刷できます。配列内の要素の数だけでなく、同様のコマンド配列を含むコンテンツも同様です。追加された行は、このコードセクションの4行と5行です。
if len(mispell_packages)+len(mispell_snaps) > max_alt:
print("", file=self.output_fd)
print(_("Command '%s' not found, but there are %s similar ones.") % (word, len(mispell_packages)), file=self.output_fd)
for x in range(len(mispell_packaged)):
print(mispell_packages[x])
print("", file=self.output_fd)
self.output_fd.flush()
return
今すぐ保存して/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py
(rootで編集する必要がある)と入力すると、int
次のようになります。
Command 'int' not found, but there are 18 similar ones.
('itd, 'ncl-ncarg', 'universe', '')
('ant, 'ant', 'universe', '')
('inl, 'ioport', 'universe', '')
('inw, 'ioport', 'universe', '')
('tint, 'tint', 'universe', '')
('inc, 'mailutils-mh', 'universe', '')
('inc, 'mmh', 'universe', '')
('inc, 'nmh', 'universe', '')
('nit, 'python-nevow', 'universe', '')
('init, 'systemd-sysv', 'main', '')
('itv, 'python-invoke', 'universe', '')
('itv, 'python3-invoke', 'universe', '')
('cnt, 'open-infrastructure-container-tools', 'universe', '')
('inb, 'ioport', 'universe', '')
('ent, 'ent', 'universe', '')
('ink, 'ink', 'universe', '')
('iyt, 'python3-yt', 'universe', '')
('iat, 'iat', 'universe', '')
リストには、同様のコマンド名(itd、and、inl、inw、Tint)と、このコマンドを提供するパッケージ(ncl-ncarg、ant、ioport)、およびそのコマンドが提供されるリポジトリ(宇宙、メイン)。
疑問が解消されたことを願っています:) 正直、私もあなたの記事を読んで気になりました。