Skip to content

Instantly share code, notes, and snippets.

@lanrion
Created April 22, 2014 06:53
Show Gist options
  • Save lanrion/11167800 to your computer and use it in GitHub Desktop.
Save lanrion/11167800 to your computer and use it in GitHub Desktop.
linux中对代码、文件查找的两个重要命令grep和find
http://www.cnblogs.com/huanghuang/archive/2011/02/25/1964788.html
1、grep [option] PATTERN [FILE...]
举个例子: 在内核目录下查找包含"request_irq"字样的文件。
cd /work/system/linux-2.6.22.6/
//*表示查找当前目录下的所有文件、目录,-R表示递归查找子目录
grep "request_irq" * -R
在内核的kernel目录下查找包含"request_irq"字样的文件。
另外一个例子:cd /work/system/linux-2.6.22.6/
//kernel 表示在当前目录的kernel子目录下查找,-R表示递归查找它的所有子目录
grep "request_irq" kernel -R
2、find [-H] [-L] [-P] [path...] [expression]
举个例子:在内核目录下查找文件名中包含"fb"字样的文件.
cd /work/system/linux-2.6.22.6/
find -name "*fb*"
另外一个例子: 在内核的drivers/net目录下查找文件名中包含"fb"字样的文件
cd work/system/linux-2.6.22.3/
find drivers/net -name "*fb*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment