Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the regular expressions for grep in bash

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "what are the regular expressions used for grep in bash", the content is simple and clear, and I hope it can help you solve your doubts, so let me lead you to study and learn about "what regular expressions are used in grep in bash".

Basic usage of text search tool grep

Function: look for strings in each line of the input file.

Basic usage:

Grep [- acinv] [- color=auto] [- A n] [- B n] 'search string' file name

Parameter description:

-a: process binary documents as text

-c: displays the number of matches

-I: ignore case differences

-n: displays the line number at the beginning of the line

-A:After, which displays n lines of data after the matching string

-B:before, which displays the data that matches the first n lines of the string

-v: shows the meaning of no matching line-A:After, shows the meaning of n lines-B:before after the matching part, and shows n lines before the matching part

-color: highlight matching keywords in a specific color

Text search tool grep regular expression metacharacter set

^

Anchor the beginning of a line such as:'^ grep' matches all lines that begin with grep.

$

The end of an anchor line such as: 'grep$' matches all lines that end in grep.

.

Matches a character that is not a newline character such as: 'gr.p' matches gr followed by any character followed by p.

*

Match zero or more previous characters such as: 'grep' matches all one or more spaces followed by the line of grep. . Used together to represent any character.

[]

Matches a specified range of characters, such as'[Gg] rep' matches Grep and grep.

[^]

Matches a character that is not in the specified range, such as:'[A-FH-Z] rep' matches a line that does not contain a letter from Amurr and Tmurz, followed by a line of rep.

(..)

The tag matches characters, such as'(love)', and love is marked as 1.

\

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report