Each operating system is made up of thousands of different kinds of files. The system itself includes files, users ' own files, shared files, and so on. Sometimes we often forget where a file is on the hard drive.
Looking up a file in Microsoft's Windows operating system is fairly straightforward, as long as you click "Start" on the desktop-"search" to find files and documents on your local hard disk, on the LAN, and even on the internet.
However, users who use Linux are less fortunate, and looking up a file on Linux is a really troublesome thing to do. After all, in Linux we need to use the dedicated "find" command to find the files on the hard disk. Nonsense not to say, the following small dong in detail for you to look at Linux to find files and find files containing the specified content commonly used commands .
Whereis < Program name >
Find the installation path for the software
-B Find only binary files
-M find Help files only
-S only find source code
-u excludes specified type files
-F displays only file names
-B < directory > find binaries under specified directory
-M < directory > Find help files in specified directory
-S < directory > find source code in specified directory
Locate < file name >
Searching for files in the file index database
-D < database path > search specified database
UpdateDB
Update file Index Database
Find [path] < expression >
Find Files
-name < expression > Find files by file name
-iname < expression > Find file based on filename, ignore case
-path < expressions > Locating files by Path
-ipath < expression > Find files based on paths, ignoring case
-amin < minutes > Files accessed in the last n minutes
-atime < days > Files accessed in the past n days
-cmin < minutes > Modified files in the past N minutes
-ctime < days > Modified files in the past n days
-anewer < reference files > files that are read later than reference files
-cnewer < reference files > files that have been modified later than the reference file
-size < size > Find files based on file size, Unit b C w K M G
-type < file type > Find files based on file type. B Block equipment c character Equipment D directory p pipeline file f normal file L link s port file
-user < user name > Find files by attribution user
-uid <uid> Find files by uid
-group < Group name > Find files by attribution Group
-gid <gid> find files by gid
-empty Find empty files
To find the line that matches the specified string from the contents of the file:
$ grep "found string" filename
To find the rows that match a regular expression from the contents of the file:
$ grep–e "Regular expression" filename
Lookup is case-insensitive:
$ grep–i "found string" filename
Find a matching number of rows:
$ grep-c "found string" filename
To find rows that do not match the specified string from the contents of the file:
$ grep–v "found string" filename
Find all text files with the. log extension from the root directory, and find the rows that contain "ERROR"
Find/-type f-name "*.log" | Xargs grep "ERROR"
When the system finds the nginx.conf file, it immediately displays nginx.conf file information on the screen.
Find/-name "nginx.conf"-ls
Find a file under the root directory
Find. -name "Test"
Find a file in a directory that contains a string
Grep-r "ZH_CN".
303i files in all file contents under Circular directory
Find. -type f-exec grep-l "303i" {} \;