Sponsored Content
Top Forums Shell Programming and Scripting Regex in Shell Scripting to pick values Post 302931261 by RavinderSingh13 on Monday 12th of January 2015 07:42:08 AM
Old 01-12-2015
Quote:
Originally Posted by radioactive9
Hi

Thank you R. Singh. That is hell of a code. Almost what I need.

I need GT and GE to be listed together and not separately that is if the code sees GT or GE just pick up the value next to it. If it sees both pick both

A line can be there where we will have *GE and *GT in same formula. Pick both in same variable $valueGreater with a space is OK


Also don't want that 1 2 3 at the start

Code:
 
-bash-3.2$ valueGreater=`echo $formula | awk -vs1="GE" '{for(i=1;i<=NF;i++){if($i ~ s1){A[NR]=A[NR]?A[NR] OFS $(i+1):NR OFS $(i+1)}}}  END{for(y in A){print A[y]}}'`
-bash-3.2$echo $valueGreater
1 80.00 10
-bash-3.2$

---------- Post updated at 07:21 AM ---------- Previous update was at 07:10 AM ----------




Almost works perfectly for
Code:
 
 
*IF *VALUE MS_SQL_Server_Summary.Total_OS_CPU_Percent *GE 80.00 *AND *VALUE MS_SQL_Server_Summary.Time_Since_Startup *GE 10


But fails on

Code:
 
*IF *VALUE MS_SQL_Server_Summary.Total_OS_CPU_Percent *GT 80.00 *AND *VALUE MS_SQL_Server_Summary.Time_Since_Startup
 
*IF *VALUE MS_SQL_Statistics_Summary.Client_Count_Percent_Used *GT 90.00

Hello radioactive9,

Could you please try following and let me know if this helps, hope this will(But not tested code though).
Code:
echo $formula | awk -vs1="GE" -vs2="GT" '{for(i=1;i<=NF;i++){if($i ~ s1){A[NR]=A[NR]?A[NR] OFS $(i+1):NR OFS $(i+1)}};if($i ~ s2){D[NR]=D[NR]?D[NR] OFS $(i+1):NR OFS $(i+1)}} END{for(i in A){print A[i]};for(j in D){print D[j]}}'

Thanks,
R. Singh
 

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
LPS2PBES(1)							   User Commands						       LPS2PBES(1)

NAME
lps2pbes - generate a PBES from an LPS and a state formula SYNOPSIS
lps2pbes [OPTION]... --formula=FILE [INFILE [OUTFILE]] DESCRIPTION
Convert the state formula in FILE and the LPS in INFILE to a parameterised boolean equation system (PBES) and save it to OUTFILE. If OUT- FILE is not present, stdout is used. If INFILE is not present, stdin is used. OPTIONS
OPTION can be any of the following: -fFILE, --formula=FILE use the state formula from FILE -t, --timed use the timed version of the algorithm, even for untimed LPS's --timings[=FILE] append timing measurements to FILE. Measurements are written to standard error if no FILE is provided Standard options: -q, --quiet do not display warning messages -v, --verbose display short intermediate messages -d, --debug display detailed intermediate messages --log-level=LEVEL display intermediate messages up to and including level -h, --help display help information --version display version information AUTHOR
Written by Wieger Wesselink; Tim Willemse. REPORTING BUGS
Report bugs at <http://www.mcrl2.org/issuetracker>. COPYRIGHT
Copyright (C) 2012 Technische Universiteit Eindhoven. This is free software. You may redistribute copies of it under the terms of the Boost Software License <http://www.boost.org/LICENSE_1_0.txt>. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
See also the manual at <http://www.mcrl2.org/mcrl2/wiki/index.php/User_manual/lps2pbes>. lps2pbes mCRL2 toolset 201202.0 (Release) April 2012 LPS2PBES(1)
All times are GMT -4. The time now is 03:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy