Sponsored Content
Top Forums Shell Programming and Scripting Regex in Shell Scripting to pick values Post 302932528 by disedorgue on Thursday 22nd of January 2015 06:10:40 AM
Old 01-22-2015
Hi,
Grep is not adapted for this request, because it can not suppress many characters of global regex (in red from example):
Code:
$ echo $formula
*IF ( ( *VALUE NT_System.Operating_System_Version *EQ 4.0 *AND *VALUE NT_System.%_Total_Processor_Time *GE 90 *OR *VALUE NT_System.%_Total_Processor_Time *LT 95 ) *AND ( *VALUE NT_System.Operating_System_Version *GE 5.0 *AND *VALUE NT_Processor.%_Processor_Time *LT 95 *AND *VALUE NT_Processor.Processor *EQ '_Total' *AND *VALUE NT_Processor.%_Processor_Time *GE 90 ) )
$ echo $formula | grep -o "[^. ]*\.[^. ]* \*\(EQ\|LT\|LE\|GT\|GE\|NE\) \([^ ]*\|( *[^ ]* *)\|'[^']*'\) *)* *\(\*\AND\|\*\OR\)*"
NT_System.Operating_System_Version *EQ 4.0 *AND
NT_System.%_Total_Processor_Time *GE 90 *OR
NT_System.%_Total_Processor_Time *LT 95 ) *AND
NT_System.Operating_System_Version *GE 5.0 *AND
NT_Processor.%_Processor_Time *LT 95 *AND
NT_Processor.Processor *EQ '_Total' *AND
NT_Processor.%_Processor_Time *GE 90 )

In bash, we can resolve by suppress before, but not the best solution:
Code:
$ echo ${formula//[)(]/} | grep -o "[^. ]*\.[^. ]* \*\(EQ\|LT\|LE\|GT\|GE\|NE\) \([^ ]*\|( *[^ ]* *)\|'[^']*'\) *)* *\(\*\AND\|\*\OR\)*"
NT_System.Operating_System_Version *EQ 4.0 *AND
NT_System.%_Total_Processor_Time *GE 90 *OR
NT_System.%_Total_Processor_Time *LT 95 *AND
NT_System.Operating_System_Version *GE 5.0 *AND
NT_Processor.%_Processor_Time *LT 95 *AND
NT_Processor.Processor *EQ '_Total' *AND
NT_Processor.%_Processor_Time *GE 90

Regards.
This User Gave Thanks to disedorgue For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regex to pick up name from the following including carriage return at end of the line

has anyone got any suggestions how i would pick up the string as part of a substitution inclusive of the carriage return. ie i want to pick up <<NAME>> from the PS output but the <<; seems to be on the line before the NAME. Any ideas are appreciated! ... (3 Replies)
Discussion started by: Shakey21
3 Replies

2. UNIX for Dummies Questions & Answers

Concatenating arrays cell values in shell scripting

Hi All, I want to concatenate the array cell values and form a string.. Is it possible? for ex. I have an array word_array contains d u m b and after concatenating the string shld be 'dumb' thanks (2 Replies)
Discussion started by: mathur
2 Replies

3. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

4. Shell Programming and Scripting

Need help to change XML values with shell scripting for Network Simulation

Hello, I don't have experience in this scripting and I need some help to read a value from an XML file and change it with a random number to use in simulator for different network scenarios. </Description><sim_comm_rounds>35</sim_comm_rounds><num_clusters>1</num_clusters><Clocking> I want to... (5 Replies)
Discussion started by: erhanasd
5 Replies

5. Shell Programming and Scripting

mapping of values in shell scripting

sample content of file1: SSTY1 2145228348 652011011715140100000002419005432092074 008801726143662 VDZX01 MIO2 008801726143662 SSRTY 2145228349 ... (3 Replies)
Discussion started by: vsachan
3 Replies

6. Shell Programming and Scripting

Assigning array values using awk in shell scripting

hi My script as below #!/bin/ksh for i in `seq 1 7` do a=$(awk '{print $i}' /home/rama/expenese.txt) done for i in `seq 1 7` do echo "${a}" done content of expense.txt is as below 5032 210179 3110 132813874 53488966 11459221 5300794 I want output as... (6 Replies)
Discussion started by: Ramakrishna V
6 Replies

7. UNIX for Dummies Questions & Answers

How to compare to values returned from sql in shell scripting?

hey i am using this code to connect to sql , store the value in variable and then compare it with another variable after some time by executing the same query but the desired result is not coming #!/bin/bash val=$(sqlplus -s rte/rted2@rel76d2 <<ENDOFSQL set heading off set feedback off... (11 Replies)
Discussion started by: ramsavi
11 Replies

8. Shell Programming and Scripting

Need to pick max values of the columns

Hi, I have sar disk reports like below sample: 01:01:00 hdisk24 0 0.0 0 0 0.0 0.0 hdisk15 0 0.0 0 3 0.0 5.5 hdisk20 0 0.0 2 1 0.0 1.9 hdisk19 1 ... (3 Replies)
Discussion started by: reddyr
3 Replies

9. UNIX for Dummies Questions & Answers

How to use square values in Shell Scripting?

:wall: Hi I am a newbie with Shell Scripting who stuck while creating a shell script for Pythagoras theorem.I need to know how to add the squares for the value in shell scripting(for eg: b2 =a2 +c2). Thanks VR (4 Replies)
Discussion started by: VoraciousReader
4 Replies

10. Shell Programming and Scripting

How to calculate avg values of csv file using shell scripting .?

hi all i have a reporting work and i want it to be automated using shell scripting kindly let me know how can i make that possibe . eg data are :... (2 Replies)
Discussion started by: Avinash shaw
2 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 09:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy