ディレクトリパスに対してのみ検索結果を取得できますか?いくつかのオプションでfindを使用するか、grepまたは他のユーティリティを使用して結果をフィルタにリンクしますか?
私は似たようなことがうまくいくとfind | grep */$
思いましたが、そうではありません。特定の名前のフォルダを「検索」した別のテストでヒットを取得しているようですが、folder_name$
何もありませんfolder_name/$
。これは直観にずれているようです。で終わる行を見つけるためにgrepする方法は/
?
ベストアンサー1
はい、これは-type d
このオプションの目的です。
たとえば、
$ find /boot -type d
/boot
/boot/grub
/boot/grub/locale
/boot/grub/fonts
/boot/grub/i386-pc
マニュアルページの関連部分は次のとおりです。
-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)