GNU/Linux >> Linux の 問題 >  >> Linux

`tree`コマンドに複数の無視パターンを指定するにはどうすればよいですか?

本番システムのディレクトリ構造を印刷する必要があり、ツリーから特定のディレクトリを削除したいですか?

treeに複数の無視パターンを指定するにはどうすればよいですか コマンド?

承認された回答:

すべてのパターンを-Iに提供するだけです |で区切られたコマンド 。マンページから:

-P pattern
      List  only  those files that match the wild-card pattern.  Note:
      you must use the -a option to also consider those  files  begin‐
      ning  with a dot `.' for matching.  Valid wildcard operators are
      `*' (any zero or more characters), `?' (any  single  character),
      `[...]'  (any single character listed between brackets (optional
      - (dash) for character  range  may  be  used:  ex:  [A-Z]),  and
      `[^...]'  (any  single character not listed in brackets) and `|'
      separates alternate patterns.

-I pattern
      Do not list those files that match the wild-card pattern.

たとえば、

tree -I 'test*|docs|bin|lib'

「docs」、「bin」、「lib」、ディレクトリ、および名前に「test」が含まれるディレクトリは、ディレクトリ階層内のどこにあってもスキップします。もちろん、ワイルドカードを適用して、はるかに強力なマッチングを行うことができます。


Linux
  1. Sedコマンドで一度に複数のパターンを使用する

  2. 複数のパターンでGrepを実行する方法は?

  3. 単一のコマンドに対してBashでエイリアスを無効にする方法は??

  1. Linuxで「find」コマンドを使用して複数のファイル名(拡張機能)を検索する方法

  2. Linux で特定のユーザーに対して特定のコマンドを無効にする方法

  3. diff コマンドのいくつかの違いを無視するには?

  1. 複数のウィンドウのパスワードを入力する方法は?

  2. Linuxで一度に複数のファイルの名前を変更する方法

  3. Linux コマンドのソース コードを入手する