Find files and find files commonly used commands that contain the specified content under [reprint] linux.

Find files and find files under linux common commands that contain the specified content.

 

Each operating system is composed of thousands of different types of files thereof. Which comes with its own file system, the user's own files, as well as share files and so on. Sometimes we often forget that a document on which local hard disk.

Microsoft's Windows operating system you want to find a document is fairly simple thing, just click "Start" on the desktop - "Search" will be able to, local area network, or even look in the INTERNET on a local hard disk in a variety of ways all kinds of files, documents.

But the use of Linux users are not so lucky, find a file is really a troublesome thing on Linux. After all, in Linux we need to use a dedicated "find" command to find the file on your hard disk. Ado, here Dong to tell you about it in detail to find the file and find the file containing the content commonly used commands under Linux .

whereis <program name>
to install the software Pathfinder
-b find only binary files
-m only to find help file
-s only to find the source code
-u exclude specific types of files
-f only displays the file name
-B <directory> Find in the specified directory binary file
-M <directory> Find help files in the specified directory
-S <catalog> Find the source code in the specified directory

locate <filename>
in the file index database to search for files
-d <database path> Specifies the search database
updatedb
update file index database

find [path] <expression>
Find files
-name <expression> Find the file based on the file name
-iname <expression> Find files by file name, ignoring case
-path <expression> Find files based on the path
-ipath <expression type> Find files based on the path, ignoring case
-amin <minute> file visited in the past N minutes
-atime <days> N file past days visited
modified in the last N minutes -cmin <minute> file
-ctime <days> last N days modified files
-anewer <reference file> is later than the reference file is read file.
-cnewer <reference file> is later than the reference file has been modified file.
-size <size> the file Find the file size, MG unit bcwk
The -type <type> files by file type. block device b c d directory p conduit character device file link f l s port common file file
-user <username> look for files in user home
-uid <uid> look for files in the UID
-group <group name> group by the home Find files
-gid <gid> Find by GID file
-empty find an empty file

Find the line that matches the specified string from the contents of the file:

Grep $ "search string" filename 

Find the line that matches the regular expression from the contents of the file:

Grep $ - E "regular expression" filename 

Case-insensitive when looking for:

Grep $ - i "search string" filename 

Find the number of matching rows:

Grep $ - c "search string" filename 

Find the line does not match the specified string from the contents of the file:

Grep $ - v "search string" filename 

Find all start from the root directory of the extension .log text file and find the line containing "ERROR" of

find / -type f -name "*.log" | xargs grep "ERROR"

After finding the file system nginx.conf nginx.conf files instantly displays information on the screen.

find/-name"nginx.conf"-ls

Find a file in the root directory

find . -name "test"

In a directory to find the file that contains a string of

grep -r "zh_CN" ./

Under cycling list of all files contained in the content file 303i

find . -type f -exec grep -l "303i" {} \;

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11579612.html
Recommended