GNU findを使用して一度に複数のファイル形式を検索する方法は?

GNU findを使用して一度に複数のファイル形式を検索する方法は?

GNU findコマンドを使用して一度に複数のファイル形式を一致させる方法(1つの検索コマンド)?

マニュアルページには次のように記載されています。

-type c
    File is of type c:
    b      block (buffered) special
    c      character (unbuffered) special
    d      directory
    p      named pipe (FIFO)
    f      regular file
    l      symbolic link; this is never true if the -L option or the -follow
           option  is in  effect,  unless  the  symbolic link is broken.  If
           you want to search for symbolic links when -L is in effect, use
           -xtype.
    s      socket
    D      door (Solaris)

fファイル()とシンボリックリンク(l)を検索して別のプロセスにパイプしたいです。同時に検索するには?

頑張りました

find -type fl | …
find -type f -type l | …
find -xtype f -type l | …

解決策はサブシェルを使用することです。

(find -type f; find -type l) | …

しかし、私はただ知りたいです。もし可能。

ベストアンサー1

findを使用して論理演算子をグループ化して使用できますが、すべてのファイルとリンクを見つけるには角かっこをエスケープする必要があります。

find \( -type f -o -type l \) <other filters>

したがって、名前がtで始まるすべてのファイルとリンクが必要な場合は、次のことができます。

find \( -type f -o -type l \) -name 't*'

括弧は、項目をグループ化して他の演算子と組み合わせる場合にのみ必要であるため、他の検索基準がない場合は省略できます。

おすすめ記事