
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*'
括弧は、項目をグループ化して他の演算子と組み合わせる場合にのみ必要であるため、他の検索基準がない場合は省略できます。
答え2
この試み:
find -type f -o -type l
答え3
-a
and
(for)または(for)を使用して-o
述語を結合できますor
。したがって、次のように入力できます。
find /path -type f -o -type l