Linux Find/grep Commands

Source: Internet
Author: User

First, Find

1) Delete files in bulk

Find " *.h~ " RM ' {}' \;

2) Locate a file line

Find/-name "demo.conf" | Egrep-v "Default" | Xargs grep-n "Demo"  | head-1 | cut-d "/"-F 4

3) Find a first-level directory

Find/-type d-maxdepth 1-mindepth 1 | Egrep-v "(Default|global|htdoc)

4) Replace the file with a line

Find/-name "demo.conf" | Egrep-v "Default" | Xargs sed-i ' i/demo/demo:test/g '

5) Insert content after a line in the file

Find/-name "demo.conf" | Xargs sed-i "$ (Find/-name" demo.conf "| egrep-v" Default "| Xargs grep-n" Demo "  | head-1 | cut-d": "-F 4) ' Ade Mo\ndemo '

Reference: http://blog.jobbole.com/48931/

Second, Grep

grep get_default_error_string *-rfn--binary-files=without-match

Third, regular expression

http://www.cnblogs.com/yirlin/archive/2006/04/12/373222.html
http://www.jb51.net/article/31235.htm

Linux Find/grep Commands

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.