Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ grep regular expression     - Security implementation of disk data protection under Linux (Linux)

- PHP file upload methods exist in the database (Programming)

- SSH without password (Linux)

- CentOS7 build GlusterFS (Linux)

- Servlet life cycle code examples (Programming)

- CentOS 7 hard disk expansion toss record (Linux)

- To access an Oracle database using Instant Client (Database)

- GNU Linux use diff to generate a patch with the patch (Linux)

- Five Linux user space debugging tool (Linux)

- Zabbix installation under Linux (Server)

- How do I switch from NetworkManager to systemd-network on Linux (Linux)

- Spring declarative transaction management (Programming)

- Nginx + ownCloud + PHP + MySQL to build personal private cloud under CentOS7 (Server)

- Process monitoring tools Supervisor start MongoDB (Database)

- Apache POI Excel Document Processing (Linux)

- Python data types summary (Programming)

- File sharing and fork function (Programming)

- Linux server security - the web server configuration (Linux)

- installation and configuration of the PHP environment (Apache2) under Linux (Server)

- Oracle set the timer task JOB scheduler to execute stored procedures or PL / SQL code block (Database)

 
         
  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:      
 
- Repair fatal error in Linux: lame / lame.h: No such file or dir Error (Linux)
- SVN common commands (Linux)
- Ubuntu 14.04 installed Nvidia CUDA 7.5 and build Python Theano deep learning development environment (Linux)
- Usage of sudo (Linux)
- You can not ignore the seven Git tips (Linux)
- Memcached distributed caching (Server)
- Use 3G wireless network card under Linux (Linux)
- Source compiler install Nginx (Server)
- Java thread lifecycle (Programming)
- Ubuntu 14.04 build Gitlab (Linux)
- 12 Linux Process Management Commands (Linux)
- CentOS Nginx achieve 3 virtual machine load balancing (Server)
- Use Ansible efficient delivery Docker container (Server)
- Configuring automatic mail GAMIT under CentOS system (Linux)
- Use the TC flow control test under Linux (Linux)
- Linux text processing tool of sed (Linux)
- Quota for Vsftpd do use disk quotas (Server)
- CentOS 6.5 Linux System Customization and Packaging Quick Implementation Script (Linux)
- Vi syntax highlighting settings (Linux)
- Build RPM package uses Docker mirror (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.