so i have the above command which works wonderfully. but i found myself in a situation i didn't expect.
first, i believe the code I bolded above can be incorporated into the preceding awk calculations. any ideas on how to do that?
second, i need to find a way to only show output if and only if the numbers in field 4 ($4), after the calculations are done, is above two interesting numbers.
so the interesting numbers would be something like:
so i want to alert if the numbers is either greater than and/or equal to -2 (negative 2) or greater than or equal to 2 (positive 2).
so in this context, for example, -3 should be considered greater than or equal to -2. and 3 of course should be considered greater than or equal to 2 as well.
any ideas on how to modify the above code to do that, efficiently?
and while i'm aware that -3 is not bigger than -2, what i meant to say was, i want to catch values that are less than or equal to -2. in which case, and in the context you are thinking, would mean numbers like -2, -3, -4, -5, -6, etc.
so i have the above command which works wonderfully. but i found myself in a situation i didn't expect.
first, i believe the code I bolded above can be incorporated into the preceding awk calculations. any ideas on how to do that?
second, i need to find a way to only show output if and only if the numbers in field 4 ($4), after the calculations are done, is above two interesting numbers.
so the interesting numbers would be something like:
so i want to alert if the numbers is either greater than and/or equal to -2 (negative 2) or greater than or equal to 2 (positive 2).
so in this context, for example, -3 should be considered greater than or equal to -2. and 3 of course should be considered greater than or equal to 2 as well.
any ideas on how to modify the above code to do that, efficiently?
I'm very confused by this thread. Using the above code with OUTPUT set to:
(which uses echo to change the two spaces before the second occurrence of survey= into a single space) feeds a single line into gawk. Even if $OUTPUT expanded to contain multiple lines, the echo would convert any adjacent sequence of one or more <space>, <tab>, and <newline> characters into single <space> characters in the data passed in to gawk. Therefore, all of the conditions marked in red above will ALWAYS evaluate to false.
And, you said the above script is working correctly, but you want it to run faster by combining the two invocations of gawk into a single invocation of gawk (or awk), but the description of what you want the code:
to do, doesn't even come close to what this code does. If WARNING is set to -2 and CRITICAL is set to 2, this code will print the single input line to your script if and only if $4 in your input (85.6701 in your sample input) is between -2 and 2. Since 85.6701 is not between -2 and 2, your script will produce no output for your sample input. Borrowing from Chubler_XL and taking SriniShoo's evaluation to the next step, your code could be optimized to something like:
Or, to match your various English descriptions of how $WARNING and $CRITICAL are to be used, change:
to:
or, maybe:
This User Gave Thanks to Don Cragun For This Post:
In addition to the observations made earlier, I think the script could be reduced to something like this, without arrays and enumeration in the END section. With i representing the $2 value V(N) and j representing V(N+1) ..
Hi All,
I have written a new script to check for DB space and size of dump log file before it can be imported into a Oracle DB.
I'm relatively new to shell scripting.
Please help me optimize this script further. (0 Replies)
Hi guys,
I feel a bit comfortable now doing bash scripting but I am worried that the way I do it is not optimized and I can do much better as to how I code.
e.g.
I have a whole line in a file from which I want to extract some values.
Right now what I am doing is :
STATE=`cat... (5 Replies)
Hello,
I'm wondering if there is a quicker way of doing this.
Here is my mv script.
d=/conversion/program/out
cd $d
ls $d > /home/tempuser/$$tmp
while read line ; do
a=`echo $line|cut -c1-5|sed "s/_//g"`
b=`echo $line|cut -c16-21`
if ;then mkdir... (13 Replies)
Hi,
I have to assign a value for a varaiable based on a Input. I have written the below code:
if
then
nf=65
elif
then
nf=46
elif
then
nf=164
elif
then
nf=545
elif
then
nf=56
elif
then (3 Replies)
Pl help to me to write the below code in a simple way ...
i suupose to use this code 3 to 4 places in my makefile(gnu) ..
****************************************
@for i in $(LIST_A); do \
for j in $(LIST_B); do\
if ;then\
echo "Need to sign"\
echo "List A = $$i , List B =$$j"\
... (2 Replies)
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
can we optimize this command ?
sed 's#AAAA##g' /study/i.txt | sed '1,2d' | tr -d '\n\' > /study/i1.txt;
as here i am using two files ...its overhead..can we optimise to use only 1 file
sed 's#AAAA##g' /study/i.txt | sed '1,2d' | tr -d '\n\' > /study/i.txt;
keeping them same but it... (9 Replies)
Hi,
I have this following script below. Its searching a log file for 2 string and if found then write the strings to success.txt and If not found write strings to failed.txt . if one found and not other...then write found to success.txt and not found to failed.txt.
I want to optimize this... (3 Replies)