ディレクトリのみの検索を使用する方法

ディレクトリのみの検索を使用する方法

これにより、「Dropnot」のさまざまなサブディレクトリに多数のファイルを見つけることができます。

$ locate Dropnot

私が見つけることができますただディレクトリの場所はlocate? (「Dropnot」があるディレクトリ)

したがってDropnot、にある場合、/home/me/これが返される唯一の項目です。

それでは、最も簡単で短い方法は何ですか?

出力をパイピングして見つけるよりも、フラグやシンボルを見てみるのが良いでしょうが、私は何かを選びます。

行末を表す一種のDropnot $がありますか? (しかしそれはうまくいきませんでした)。

ベストアンサー1

私はmlocateそれをインストールしました。デフォルトではRedHatから配布されるため、Fedora、RHEL、CentOSで動作します。 ~からman locate

-b, --basename
       Match only against the file name portion of the path name,  ie.,  the  
       directory  names will be excluded from the match (but still printed). 
       This does not speed up the search, but can suppress uninteresting matches.

したがって、実行すると、locate -b '/Dropknot'その文字列を含むファイルまたはディレクトリのみが報告されます。

おすすめ記事