find $HOME -name "hello.c" -print
$HOMEこれにより、システム全体(つまり/home/username/) で「hello.c」という名前のファイルが検索され、それらのパス名が表示されます。
/Users/user/Downloads/hello.c
/Users/user/hello.c
HELLO.Cただし、または一致しませんHellO.C。一致させるには、大文字と小文字を区別しません-iname。次のようにオプションを渡します。
find $HOME -iname "hello.c" -print
サンプル出力:
/Users/user/Downloads/hello.c
/Users/user/Downloads/Y/Hello.C
/Users/user/Downloads/Z/HELLO.c
/Users/user/hello.c
-type fファイルのみを検索するオプションを渡します。
find /dir/to/search -type f -iname "fooBar.conf.sample" -print
find $HOME -type f -iname "fooBar.conf.sample" -print
-inameGNU または BSD (OS X を含む) バージョンのfind コマンドで動作します。お使いのバージョンの find コマンドが をサポートしていない場合は、コマンド-inameを使用して次の構文を試してください。grep
find $HOME | grep -i "hello.c"
find $HOME -name "*" -print | grep -i "hello.c"
または試す
find $HOME -name '[hH][eE][lL][lL][oO].[cC]' -print
サンプル出力:
/Users/user/Downloads/Z/HELLO.C
/Users/user/Downloads/Z/HEllO.c
/Users/user/Downloads/hello.c
/Users/user/hello.c