1.在某個路徑下查找一個指定的文件:
find pathname -name "filename"
eg: find /usr/ -name "stdio.h" //在usr目錄下查找stdio.h頭文件。
2.在某個路徑下查找包含一個指定的字符串的所有文件:
grep -rl "stringname" pathname
eg:grep -rl "BUFSIZ" ./ //在當前目錄下查找包含宏"BUFSIZ"的文件
3.在某個文件裏面查找一個指定的字符串
grep "stringname" filename
eg:grep "BUFSIZ" stdio.h //在文件stdio.h裏查找宏"BUFSIZ"默認輸出所在行