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.
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 ?
Your source is a multiline textfile.
Your expected output is "match" or "not matched".
Still dont konw wether that is per item/line or for the whole file.
If it is for the whole file, it still isnt clear wether 'match' shall be printed if any (at least) or multiple are to be found.
Please enlight.
(Too late already again to read properly)
EDIT ----------------
num=$(grep Normal input_file|wc -l)
[ $num -eq 4 ] && echo Match || echo "No match"
It is quite possible to do this just using shell built-ins, but only if we understand what you're trying to do.
Where is your data stored? Is it in a file or is it stored in a shell variable?
Is the goal to find four occurrences of Normal , or is the goal to determine if every line that contains status: also contains Normal ? (Or, is there some other rule that determines the desired output?)
Instead of just showing us an RE, show us how you are using that RE to get the results you want. It is hard to simplify an RE if we don't know the context in which it is being utilized. Show us the code (in CODE tags) you are using (if you have something working that you want to simplify) or show us the code you have tried (if you don't have a working solution yet).