find $HOME -name "hello.c" -print
Thao tác này sẽ tìm kiếm toàn bộ hệ thống $HOME(ví dụ /home/username/) cho bất kỳ tệp nào có tên là hello hello.c và hiển thị tên đường dẫn của chúng:
/Users/user/Downloads/hello.c
/Users/user/hello.c
Tuy nhiên, nó sẽ không phù hợp HELLO.Choặc HellO.C. Để phù hợp là trường hợp không nhạy cảm vượt qua -inametùy chọn như sau:
find $HOME -iname "hello.c" -print
Đầu ra mẫu:
/Users/user/Downloads/hello.c
/Users/user/Downloads/Y/Hello.C
/Users/user/Downloads/Z/HELLO.c
/Users/user/hello.c
Vượt qua -type ftùy chọn để chỉ tìm kiếm tệp:
find /dir/to/search -type f -iname "fooBar.conf.sample" -print
find $HOME -type f -iname "fooBar.conf.sample" -print
Các -inamehoạt động trên lệnh tìm phiên bản GNU hoặc BSD (bao gồm cả OS X). Nếu phiên bản lệnh find của bạn không hỗ trợ -iname, hãy thử cú pháp sau bằng cách sử dụng greplệnh:
find $HOME | grep -i "hello.c"
find $HOME -name "*" -print | grep -i "hello.c"
Hay là thử
find $HOME -name '[hH][eE][lL][lL][oO].[cC]' -print
Đầu ra mẫu:
/Users/user/Downloads/Z/HELLO.C
/Users/user/Downloads/Z/HEllO.c
/Users/user/Downloads/hello.c
/Users/user/hello.c
man grep, câu hỏi thứ hai vớiman find. Tại sao bạn google thay vì sử dụng người đàn ông, tôi không biết.