Common commands are used to find files or content in linux.
Source: Internet
Author: User
Type & lt; file type & gt; search for files based on the file type. Block B device c character device d Directory p Channel file f common file whereis <程序名称>
Find the software installation path
-B: only query binary files.
-M: only search for help files
-S: only find the source code
-U: exclude files of the specified type.
-F only displays file names
-B <目录> Search for binary files in a specified directory
-M <目录> Search for help files in the specified directory
-S <目录> Find the source code in the specified directory
Locate <文件名称>
Search for files in the file index database
-D <数据库路径> Search for a specified database
Updatedb
Update a file index database
Find [path] <表达式>
Search for files
-Name <表达式> Search for files by file name
-Iname <表达式> Search for files by file name, case insensitive
-Path <表达式> Search for files by path
-Ipath <表达式> Search for files by PATH, case insensitive
-Amin <分钟> Files accessed in the past N minutes
-Atime <天数> Files accessed in the past N days
-Cmin <分钟> Files modified in the past N minutes
-Ctime <天数> Files modified in the past N days
-Anewer <参照文件> Objects read later than the reference file
-Cnewer <参照文件> Files modified later than the reference files
-Size <大小> Search for files based on the file size, in the unit of B c w k M G
-Type <文件类型> Search for a file based on the file type. Block B device c character device d Directory p pipeline file f common file l link s Port file
-User <用户名> Search for files by owner user
-Uid Search for files by UID
-Group <群组名> Search for files by group
-Gid Search for files by GID
-Empty
Find the row matching the specified string from the file content:
$ Grep "searched string" file name
Find the row matching the regular expression from the file content:
$ Grep-e "regular expression" file name
Case insensitive when searching:
$ Grep-I "searched string" file name
Find the number of matched rows:
$ Grep-c "searched string" file name
Find rows that do not match the specified string from the file content:
$ Grep-v "searched string" file name
Search for all text files with the extension. log in the root directory and find the rows containing "ERROR ".
Find/-type f-name "*. log" | xargs grep "ERROR"
After finding the httpd. conf file, the system displays the httpd. conf file on the screen.
Find/-name "httpd. conf"-ls
Search for a file in the root directory
Find.-name "test"
Search for files containing a string in a directory
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.