Find a file in a directory that contains a string under Linux

Source: Internet
Author: User

Sometimes I have to find some strings, but I don't know which file, just remember some strings

So how do you find files that contain a piece of text under Linux?

A powerful find command can help you accomplish an impossible task.

For example, I only remember my program contains a unique string "Sms_issend", so:

Find if all files in the directory contain a string

Find. | Xargs Grep-ri "Sms_issend"

Finds all files in the directory that contain a string, and prints only the file name

Find. | Xargs Grep-ri "Sms_issend"-l

Find a file in a directory that contains a string under Linux

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.