10-14-2015
[solved] Delete row if both percentage values are equal to zero
Hello,
I have compiled a script but I have stucked at one point.
Each line contains two pcs of % value and what I want to do is to delete any line if both % values are zero.
data:
Quote:
ow1" class=alt1 onMouseOver='setupdateRow(1)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=1'>aaa.bbb.ccc.ee:10004</a></td><td><img src='/RU.gif' title='Russia'> aaa.bbb.ccc.ee</td><span style="float: right;">3%</span></td><td>561<span style="float: right;">10%</span></td></tr>
ow2" class=alt2 onMouseOver='setupdateRow(2)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=2'>xx.yy.zz.ee:5555</a></td><td><img src='/DE.gif' title='Germany'> xx.yy.zz.ee</td><span style="float: right;">45%</span></td><td>7304<span style="float: right;">10%</span></td></td></tr>
ow3" class=alt2 onMouseOver='setupdateRow(2)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=5'>aa.yy.zz.ee:3333</a></td><td><img src='/DE.gif' title='Germany'> aa.yy.zz.ee</td><span style="float: right;">0%</span></td><td>7304<span style="float: right;">0%</span></td></td></tr>
ow4" class=alt2 onMouseOver='setupdateRow(2)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=9'>hh.yy.zz.ee:4444</a></td><td><img src='/DE.gif' title='Germany'> hh.yy.zz.ee</td><span style="float: right;">22%</span></td><td>7304<span style="float: right;">0%</span></td></td></tr>
expected output:
Quote:
ow1" class=alt1 onMouseOver='setupdateRow(1)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=1'>aaa.bbb.ccc.ee:10004</a></td><td><img src='/RU.gif' title='Russia'> aaa.bbb.ccc.ee</td><span style="float: right;">3%</span></td><td>561<span style="float: right;">10%</span></td></tr>
ow2" class=alt2 onMouseOver='setupdateRow(2)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=2'>xx.yy.zz.ee:5555</a></td><td><img src='/DE.gif' title='Germany'> xx.yy.zz.ee</td><span style="float: right;">45%</span></td><td>7304<span style="float: right;">10%</span></td></td></tr>
ow4" class=alt2 onMouseOver='setupdateRow(2)' onMouseOut='setupdateRow(0)'><td><a href='/connector?id=9'>hh.yy.zz.ee:4444</a></td><td><img src='/DE.gif' title='Germany'> hh.yy.zz.ee</td><span style="float: right;">22%</span></td><td>7304<span style="float: right;">0%</span></td></td></tr>
ow3 should be deleted as both percentage value in related line are equal to zero.
Thanks in advance
Boris
Last edited by baris35; 10-14-2015 at 08:09 AM..
Reason: [solved]
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I am having the file which contains the following two columns.
518 _factorial
256 _main
73 _atol
52 ___do_global_ctors
170 ___main
52 ___do_g
How can calculate the percentage of each value in the first column ?
first need to get the sum of the first column and... (3 Replies)
Discussion started by: saleru_raja
3 Replies
2. Shell Programming and Scripting
Hi
I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example.
The original data record should be some thing like this
60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies
3. Shell Programming and Scripting
Does anybody understand why this is not being interpreted as true.
Script:
#!/bin/bash
errored=`grep "errored" new_update_scripts.txt`
echo $errored = "errored"
if ; then
echo true
else
echo false
fi
Output:
$ UpdateScripts
errored = errored
false (7 Replies)
Discussion started by: scottwmackey
7 Replies
4. UNIX for Dummies Questions & Answers
Hi,
For each row in a file, i would like to identify the maximum value and calculate the percentage/fraction of the max for other values in the row.
Then, I would like to print a copy of the file where values above a threshold are replaced with "1" and other values are left as "0".
In the... (2 Replies)
Discussion started by: auburn
2 Replies
5. UNIX for Dummies Questions & Answers
Hi there,
I am totally new to Unix, I am trying to work out the percentage between two values in a ksh shell script and assign the result to a variable.
Value1=577
Values2=244
So the calculation would be as follows:
((Value1 - Value2) / Value1) * 100
How would I be able to achieve... (2 Replies)
Discussion started by: NextLevelAndi
2 Replies
6. Shell Programming and Scripting
Hi all
I am trying to scan a file that has 3 columns:
red blue 123351
red blue 848655
red blue 126354
red blue 023158
black white 654896
red blue 650884
I want an output that sums the rows that have matching columns 1 and 2 :wall:
red blue has 5 entries
black white has 1 entry
... (4 Replies)
Discussion started by: reno
4 Replies
7. Shell Programming and Scripting
Hi,
I have n number of values like
1
2
3
4
I want the output like
1 2 3
4 5 6
- - -
- - -
Please help me on this:wall: (4 Replies)
Discussion started by: cns1710
4 Replies
8. Shell Programming and Scripting
file content are like this
sam,22,29,23,24,25,26,22
i want to add the values from column 3 (fix column no) to as per user input say up to column 8 (variable as per user)
can we do this without using "awk" for each column (as number of columns are variable as per user input )
Thanks in... (5 Replies)
Discussion started by: sagar_1986
5 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I have a tab delimited text file where some lines have the string "NA" in the second column. For these lines, I want to replace NA with the value in the first column, the symbol underscore followed by the value in the fourth column. How do I go about doing that? Thanks!
Input:
1 ... (3 Replies)
Discussion started by: evelibertine
3 Replies
10. Shell Programming and Scripting
Hello everyone,
I have a requirement as shown below. I need to delete consecutive same values from the source file and give it as output file.
Source:
a,b,c,d,e,e,f,g
Target:
a,b,c,d,f,g
The repeating value "e" should be deleted from the file completely. How can I achieve this... (14 Replies)
Discussion started by: vamsikrishna928
14 Replies
LEARN ABOUT OSX
osascript
OSASCRIPT(1) BSD General Commands Manual OSASCRIPT(1)
NAME
osascript -- execute AppleScripts and other OSA language scripts
SYNOPSIS
osascript [-l language] [-s flags] [-e statement | programfile] [argument ...]
DESCRIPTION
osascript executes the given script. It was designed for use with AppleScript, but will work with any Open Scripting Architecture (OSA) lan-
guage. To get a list of the OSA languages installed on your system, use osalang(1). For documentation on AppleScript itself, see
<http://www.apple.com/applescript>.
osascript will look for the script in one of the following three places:
1. Specified line by line using -e switches on the command line.
2. Contained in the file specified by the first filename on the command line. This file may be plain text or a compiled script.
3. Passed in using standard input. This works only if there are no filename arguments; to pass arguments to a STDIN-read script, you must
explicitly specify ``-'' for the script name.
Any arguments following the script will be passed as a list of strings to the direct parameter of the ``run'' handler. For example:
a.scpt:
on run argv
return "hello, " & item 1 of argv & "."
end run
% osascript a.scpt world
hello, world.
The options are as follows:
-e statement
Enter one line of a script. If -e is given, osascript will not look for a filename in the argument list. Multiple -e options may be
given to build up a multi-line script. Because most scripts use characters that are special to many shell programs (e.g., AppleScript
uses single and double quote marks, ``('', ``)'', and ``*''), the statement will have to be correctly quoted and escaped to get it past
the shell intact.
-l language
Override the language for any plain text files. Normally, plain text files are compiled as AppleScript.
-s flags
Modify the output style. The flags argument is a string consisting of any of the modifier characters e, h, o, and s. Multiple modi-
fiers can be concatenated in the same string, and multiple -s options can be specified. The modifiers come in exclusive pairs; if con-
flicting modifiers are specified, the last one takes precedence. The meanings of the modifier characters are as follows:
h Print values in human-readable form (default).
s Print values in recompilable source form.
osascript normally prints its results in human-readable form: strings do not have quotes around them, characters are not escaped,
braces for lists and records are omitted, etc. This is generally more useful, but can introduce ambiguities. For example, the
lists '{"foo", "bar"}' and '{{"foo", {"bar"}}}' would both be displayed as 'foo, bar'. To see the results in an unambiguous form
that could be recompiled into the same value, use the s modifier.
e Print script errors to stderr (default).
o Print script errors to stdout.
osascript normally prints script errors to stderr, so downstream clients only see valid results. When running automated tests, how-
ever, using the o modifier lets you distinguish script errors, which you care about matching, from other diagnostic output, which
you don't.
SEE ALSO
osacompile(1), osalang(1)
HISTORY
osascript in Mac OS X 10.0 would translate '
' characters in the output to '
' and provided c and r modifiers for the -s option to change
this. osascript now always leaves the output alone; pipe through tr(1) if necessary.
Prior to Mac OS X 10.4, osascript did not allow passing arguments to the script.
Mac OS X June 10, 2003 Mac OS X