Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ grep regular expression     - Java transient keyword (Programming)

- Use Git in Eclipse (Linux)

- Spark and Hadoop comparison (Server)

- TeamCity continuous integration in the Linux installation (Linux)

- DIY security of Linux platform (Linux)

- OpenStack package problems and solutions under CentOS6 (Linux)

- ethtool implementation framework and application in Linux (Linux)

- Getting Started with Linux: CentOS7 Install Mono with the yum command (Server)

- CentOS6 MongoDB connection solution can not break 1000 (Database)

- OpenSUSE GPG Comments (Linux)

- C language macro definition #define Usage (Programming)

- B-tree - ideas and implementation of C language code (Programming)

- Linux platform Oracle MySQL connection (Database)

- mysqldump MySQL command-line tool (Database)

- ORA-12154 TNS could not resolve the specified identifier (Database)

- Linux Disk and File Management (Linux)

- CentOS 6.6 install Oracle 11gR2 database (Database)

- Oracle 11R2 Grid Infrastructure execute root.sh script rootcrs.pl execution failed treatment (Database)

- Java environment to build a number of issues (Linux)

- Ubuntu system process is bound CPU core (Linux)

 
         
  grep regular expression
     
  Add Date : 2017-01-08      
         
       
         
  Regular expressions are a notation for identifying text mode. Linux main proceedings dealing with regular expressions is grep. grep searches and regular expression matching rows, and the results delivered to the standard output.

1. grep pattern matching

grep following manner acceptable options and arguments (where, regex regular expression)

grep [options] regex [files]
Where options are mainly in the following table:

Option Meaning Functional Description
-i ignore case ignore case
-v invert match does not match match
-l file-with-match output matching file names
-L File-without-match output does not match the file name
-c count the number of matching output (number of rows)
-n number output matching lines simultaneously preceded by the file name and line number in the file name
-h no-filename suppress the output file name

2. Special characters

Symbol Meaning Example
^ Start tag "^ abc" meet the case abc, abcd
Non ^ (in the []) "[^ abc]" satisfy example: ddd, mpd
$ End tag "abc $" satisfy example abc, mmabc
Arbitrary character "a.c" meet the case abc, fapcc
< Matching words beginning "< abc" meet the case abc, abcd
> Matching words end "abc>" meet the case abc, pmrabc
| Or "AAA | BBB" satisfy example AAA, BBBpp
3. Scope

Symbol Meaning Example
? Matches the preceding character 0 or 1 time "abc?" Examples met ab, mabcd
* Matches the preceding character >=0 second example "abc *" satisfied abbb, abcdk
+ Matches the preceding character >=1 times "abc +" satisfy example abcd, abcccdd
{} {M}, {m, n}, {m,}, {, n} Match the previous character respectively m times, m to n times, >=m times, <=n times "abc {3,5}" satisfy example abcccc, abcccccc
[] [] If not within range, choose one; the range, then choose one "m [abc] p" to meet the range of examples acpd; m [1-9] p satisfy example m8pp
() On all the elements of the candidate (inside), with | separated by "a (1 | 2 | 3) bc" satisfy example a1bc, mba3bcd
Note: {} need to be transferred in Zheng expressions, and {} () is not required.

4. Standard character class

Character Class Definition
[: Alnum:] letters and numbers, and [A-Za-z0-9] equivalent
[: Word:] [: alnum:] plus underscore _
[: Alpa:] letter, and [A-Za-z] Equivalent
[: Digit:] numbers, and [0-9] equivalent
[: Xdigit:] hexadecimal characters, and [0-9A-Fa-f equivalent]
[: Blank:] spaces and tabs
[: Graph:] visible character, expanding by 33 to 126
[: Lower:] Lowercase letters
[: Upper:] capital letters
[: Print:] printable characters
[: Space:] whitespace characters, equivalent to [trnvf]
[: Punct:] Punctuation
[: Cntrl:] ASCII control codes, including characters from 0 to 31 and 127
     
         
       
         
  More:      
 
- CentOS 6.6 compile and install phpMyAdmin configuration PostgreSQL9.4.1 (Database)
- MySQL primary and secondary replicate data inconsistencies (Database)
- Zypper command for SUSE Linux package management (Linux)
- Linux reserves the rest of the file to delete several (Linux)
- RocketMQ Message Queuing simple deployment (Linux)
- ARM runtime environment built from scratch using QEMU emulator (Linux)
- Ubuntu install Tonido private cloud services (Server)
- CentOS network configuration 7, and set the host name and IP-bound problems (Linux)
- CentOS install SVN server configuration and automatically synchronized to the Web directory (Server)
- How to Create a file can not be changed under Linux (Linux)
- Use regular expressions to check whether the input box to enter a URL (Programming)
- MySQL stored procedures execute dynamic sql statement (Database)
- To install JDK1.7 and compiler Hadoop-2.7.1 under CentOS7 (Server)
- Ubuntu install perfectly handsome terminal Guake 0.8.1 (Linux)
- Android components series Activity (Programming)
- Mumble installation source VoIP application on Ubuntu (Linux)
- Production environment Linux bonding method standby mode slave card switch (Server)
- Use Ambari rapid deployment Hadoop big data environment (Server)
- To use slay kill user processes (Linux)
- XP virtual machine under VirtualBox solve occupy 100% CPU problem (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.