Commands for finding strings under Linux

Source: Internet
Author: User
Tags string find
1. The set command can display all global parameter definitions and their values under the current shell; 2. Find and delete small files in the current directory: Find. -type f-size-10k-exec rm {} \; Description: Www.2cto.com-type f Find File-size-10k, less than 10k. "+" indicates that the system is required to list only files larger than the specified size, while using "-" indicates that the system is required to list files smaller than the specified size. 3. Traverse the folder grep a string find. -name "*c" | Xargs grep "Strings" in all C files under the current folder look for string "strings"
4. Locate a string in the file in a directory grep-r Youcode dir For example: Find Hellogrep-r in the file under Home Hello/home for example: Find hello in Files in all current directories, case-insensitive grep-ir hello. www.2cto.com from file content lookup matches the specified string of lines: $ grep "search string" file name from file contents Lookup line matching Regular expression: $ grep–e "Regular expression" file name lookup when case-insensitive: $ grep–i " Search string "File name lookup matching line number: www.2cto.com $ grep-c" search string "file name from file content lookup does not match the line of the specified string: $ grep–v" search string "file name starting from the root directory search Have a text file with a. log extension and find the line that contains "ERROR"

Commands for finding strings 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.