Sponsored Content
Top Forums Shell Programming and Scripting BASH - Regular Expressions :Looking for one word on multiple lines. Post 302964154 by popeye on Monday 11th of January 2016 01:41:14 PM
Old 01-11-2016
BASH - Regular Expressions :Looking for one word on multiple lines.

Im looking for a bash solution that will use Regular Expressions (not perl, sed or awk) to check the example data below and then give me a status.
which would be just simply Match or Mismatch.




Code:
SYS PS1 is present.
        Fan status: Normal
        Input Voltage status: Normal
        DC Output Voltage status: Normal
        Type: AC
        Thermal status: Normal

Im not asking about how to create a script to do this for me. I am asking for a "better" "nicer" regex expression than the one given below. Its just ugly ... know ?

Code:
.*Fan.*Normal.*\n.*Input.*Normal.*\n.*DC\sOutput.*Normal.*\n.*Type.*\n.*Thermal.*Normal

Thanks in advance
Pop

Last edited by Scrutinizer; 01-11-2016 at 05:09 PM.. Reason: Change quote tags to code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expressions

I'm trying to parse RichText to XML. I want to be able to capture everything between the '/par' tag in the RTF but not include the tag itself. So far all I have is this, '.*?\\par' but it leaves '\par' at the end of it. Any suggestions? (1 Reply)
Discussion started by: AresMedia
1 Replies

2. UNIX for Dummies Questions & Answers

regular expressions

Hi Gurus, I need help with regular expressions. I want to create a regular expression which will take only alpha-numeric characters for 7 characters long and will throw out an error if longer than that. i tried various combinations but couldn't get it, please help me how to get it guys. ... (2 Replies)
Discussion started by: ragha81
2 Replies

3. UNIX for Advanced & Expert Users

Regular Expressions

Hi, below is a piece of code written by my predecessor at work. I'm kind of a newbie and am trying to figure out all the regular expressions in this piece of code. It is really a tough time for me to figure out all the regular expressions. Please shed some light on the regular expressions... (3 Replies)
Discussion started by: ramky79
3 Replies

4. UNIX for Dummies Questions & Answers

Regular expressions

In regular expressions with grep(or egrep), ^ works if we want something in starting of line..but what if we write ^^^ or ^ for pattern matching??..Hope u all r familiar with regular expressions for pattern matching.. (1 Reply)
Discussion started by: aadi_uni
1 Replies

5. Shell Programming and Scripting

Regular Expressions

I am new to shell scripts.Can u please help me on this req. test_user = "Arun" if echo "test_user is a word" else echo "test_user is not a word" (1 Reply)
Discussion started by: chandrababu
1 Replies

6. Shell Programming and Scripting

Regular Expressions

Hi Ilove unix and alwyas trying to to learn unix,but i am weak in using regular expressions.can you please give me a littel brief discription that how can i understand them and how to use .your response could lead a great hand in my unix love. (1 Reply)
Discussion started by: manoj attri
1 Replies

7. Shell Programming and Scripting

Perl - Regular Expressions - Match complete word only

Hi Team, I have two strings like: xxx|yyy|Arizona Cardinals| Tell Cardinals | Cardinals bbb|Bell Earn, Jr | Bell Earn | Jayhawks | hawks I have a lookup file which has a set of strings. These need to be removed from above two strings Lookup file Contents: Bell Earn, Jr hawks... (2 Replies)
Discussion started by: forums123456
2 Replies

8. Shell Programming and Scripting

regular expression grouping across multiple lines

cat book.txt book1 price 23 sku 1234 auth Bill book2 sku 1233 price 22 auth John book3 auth Frank price 24 book4 price 25 sku 129 auth Tod import re f = open('book.txt', 'r') text = f.read() f.close() m =... (2 Replies)
Discussion started by: chirish
2 Replies

9. Shell Programming and Scripting

Regular expression to match multiple lines?

Using a regular expression, I would like multiple lines to be matched. By default, a period (.) matches any character except newline. However, (?s) and /s modifiers are supposed to force . to accept a newline and to match any character including a newline. However, the following two perl... (4 Replies)
Discussion started by: LessNux
4 Replies

10. Shell Programming and Scripting

Replacing Multiple spaces with a single space but excluding few regular expressions

Hi All. Attached are two files. I ran a query and have the output as in the file with name "FILEWITHFOURRECORDS.txt " I didn't want all the spaces between the columns so I squeezed the spaces with the "tr" command and also added a carriage return at the end of every line. But in two... (3 Replies)
Discussion started by: sparks
3 Replies
PPI::Document::Normalized(3)				User Contributed Perl Documentation			      PPI::Document::Normalized(3)

NAME
PPI::Document::Normalized - A normalized Perl Document DESCRIPTION
A "Normalized Document" object is the result of the normalization process contained in the PPI::Normal class. See the documentation for PPI::Normal for more information. The object contains a version stamp and function list for the version of PPI::Normal used to create it, and a processed and delinked PPI::Document object. Typically, the Document object will have been mangled by the normalization process in a way that would make it fatal to try to actually DO anything with it. Put simply, never use the Document object after normalization. YOU HAVE BEEN WARNED! The object is designed the way it is to provide a bias towards false negatives. A comparison between two ::Normalized object will only return true if they were produced by the same version of PPI::Normal, with the same set of normalization functions (in the same order). You may get false negatives if you are caching objects across an upgrade. Please note that this is done for security purposes, as there are many cases in which low layer normalization is likely to be done as part of a code security process, and false positives could be highly dangerous. METHODS
new The "new" method is intended for use only by the PPI::Normal class, and to get ::Normalized objects, you are highly recommended to use either that module, or the "normalized" method of the PPI::Document object itself. version The "version" accessor returns the PPI::Normal version used to create the object. functions The "functions" accessor returns a reference to an array of the normalization functions (in order) that were called when creating the object. equal $Normalized The "equal" method is the primary comparison method, taking another PPI::Document::Normalized object, and checking for equivalence to it. The "==" operator is also overload to this method, so that you can do something like the following: my $first = PPI::Document->load('first.pl'); my $second = PPI::Document->load('second.pl'); if ( $first->normalized == $second->normalized ) { print "The two documents are equivalent"; } Returns true if the normalized documents are equivalent, false if not, or "undef" if there is an error. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2005 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2011-02-25 PPI::Document::Normalized(3)
All times are GMT -4. The time now is 12:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy