Linux system How to bulk find files and file content

Source: Internet
Author: User

Like finding a keyword in all of the PHP files underneath the current directory.

The code is as follows Copy Code

Find./-name "*.php" | xargs grep ' keyword '

If you need to find something that contains special symbols, such as $, and so on, grep adds parameters

The code is as follows Copy Code

Find./-name "*.php" | Xargs grep-f ' key word '

File name Lookup

File Name Lookup method:

For example, if we know that a file contains 3 letters of SRM, it is possible to find all files containing these 3 letters in the system, and enter:

The code is as follows Copy Code

Find/etc-name ' *srm* '

This command indicates that the Linux system will look for all files containing 3 letters of SRM, such as ABSRMYZ,TIBC.SRM and so on, in the entire directory of/ETC to display the eligible files. If you also know that this file starts with the 3-letter SRM, we can also omit the front asterisk, which commands the following:

The code is as follows Copy Code

Find/etc-name ' srm* '

Some other references

Find-name april* finds files starting with April in the current directory
Find-name april* fprint file finds files in the current directory that start with April, and outputs the results to the
Find-nam E ap*-o-name may* find files that begin with AP or May
Find/mnt-name tom.txt-ftype vfat Find files with/mnt file system type Tom.txt under VFAT
Find/mnt -name T.txt! -ftype VFAT Find a file with the name Tom.txt under/MNT and the file system type is not VFAT
Find/tmp-name wa* L Find the file named WA beginning with the type Symbolic link in/tmp
-type Time-2 under/home for files that have been altered in the last two days.
Find/home-atime-1 Search for files accessed within 1 days
Find/home-mmin +60 Check for files changed 60 minutes ago in/home
find/h Ome-amin +30 Check the file that was accessed the last 30 minutes ago

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.