In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to achieve shell script regular matching file Email and write to the file", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to implement shell script regular matching Email in the file and write it to the file"!
The code is as follows:
#! / bin/bash
Function read_file () {
For line in `cat $1`
Do
If [`After $line | grep "^ [a-zA-Z0-9 colors -] * @ [Amelaza murazi -] *\. [Amurz Amurazi -] * $" `; then
Echo $line > > result.txt
Else
Echo "- -" > > result.txt
Fi
Done
}
# eg
Read_file a.txt
Attachment: common shell regular expressions
The code is as follows:
^ USER$ matches rows that contain only USER
[tty] $matches lines ending in tty
\. Match lines with periods
^ d..x..x..x matches directories where users, user groups, and other user group members have executable permissions
^ [^ l] matches the list of directories that exclude associated directories
[.* 0] any character before or after matching 0
[^ $] match blank lines
[^. * $] match any string in the match line
^. $matches lines with 6 characters
[a-zA-Z] matches any single character
[aMuz] [amerz] * matches at least one lowercase letter
[^ 0-9\ $] matches non-numeric or dollar logos
[^ 0-0A-Za-z] matches non-numeric or alphabetic
De..ce matches the first two letters as De, followed by two arbitrary characters, and finally ce.
[1.. 9] match 1 to 9
^. $matches lines with only one character
^\. [0-9] [0-9] matches lines that start with a period and two numbers
The word 'Device' matches the word device
De [VV] ice\. Match the word Device or deVice
[0-9]\ {2\}-[0-9]\ {2\}-[0-9]\ {4\} match date format dd-mm-yyyy
[^. * $] match matches any row
^ [1-9]\ d {5} $matches the zip code
((\ +? [0-9] {2pr 4}\-[0-9] {3pr 4}\ -) | ([0-9] {3pm 4}\ -))? ([0-9] {7pr 8}) (\-[0-9] +)? $/ match phone number
(\ (\ d {2jue 3}\)) | (\ d {3}\ -))? 13\ d {9} $matches the mobile phone number
(d {1 recorder 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1 recorder 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1 recorder 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1 recorder 2} | 1dd | 2 [0-4] d | 25 [0-5]) $"match IP address
[\ u4e00 -\ u9fa5] regular expressions that match Chinese characters
[^\ X00 -\ xff] matches double-byte characters (including Chinese characters)
\ n [\ s |] *\ r regular expression that matches blank lines
/. * | / regular expression that matches the HTML tag
(^\ s*) | (\ smatching $) regular expression that matches leading and trailing spaces
\ W + ([- +.]\ w +) * @\ w + ([-.]\ w +) *\.\ w + ([-.]\ w +) * regular expression that matches the Email address
^ [a-zA-z] +: / / (\\ w+ (-\\ w+) *) (\. (\\ w+ (-\\ w+) *)) * (\\?\ S*)? $matches the regular expression of the URL URL
^ [a-zA-Z] [a-zA-Z0-9 _] {4j 15} $whether the matching account is legal (begins with letters, allows 5-16 bytes, and allows alphanumeric underscores)
(\ d {3}-|\ d {4} -) (\ d {8} |\ d {7})? Match domestic phone number
^ [1-9] * [1-9] [0-9] * $matches Tencent QQ number
At this point, I believe you have a deeper understanding of "how to implement shell script regular matching Email in the file and write it to the file". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.