Basically, I need to find average of numbers which are given like:
sh average file1 file (in files can be more than one number)
->10
sh average 5 7
->6
sh average /users/file
->5
echo 5 7 | sh average
6
So basically i wrote my code but it gives me error... I am pretty sure it has to work for first two cases at least.... But I stucked with my error messages ;(
this is my code:
Code:
sum=0
n=0
for i in $*
do
if [ -f $i ]
then
while read line
do
n=` expr $n + 1 `
sum=` expr $sum + $line `
done < $i
else
sum=` expr $sum + $i `
n=` expr $n + 1 `
fi
done
average=` expr $sum / $n `
echo $average
Helo guys, this is not specifically a C programming problem for the unix platform, but a problem i came across in class:
Find the average for a binary search tree:
typedef Struct SNode
{
double value;
SNode *leftChild;
SNode *rightChild;
} as SNode;
/*
* Solution 1
*/
... (2 Replies)
Hi,
I have MyLog.log file, and it contains "*** response Time 150",
I want to develop Unix script like ,
1. extract all such occurances in the MyLog.log file and
2. compute the average time taken
I am new to Unix, any one can give any idea/sample code for this?
Thanks in advance. (1 Reply)
Hello all, I have a question about load averages.
I've read the man pages for the uptime and w command for two or three different flavors of Unix (Red Hat, Tru64, Solaris). All of them agree that in the output of the 2 aforementioned commands, you are given the load average for the box, but... (3 Replies)
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more... (2 Replies)
If I have a file like this, could anyone please guide me how to find the average value in each metrix. The file has got about 130,000 metrixs.
Grid-ref= 142, 235
178 182 203 240 273 295 289 293 283 262 201 176
167 187 187 246 260 282 299 312 293 276 230 191
169 ... (2 Replies)
Hello AlL,..
I want from experts to help me as my load average is increased and i dont know where is the problem !!
this is my top result :
root@a4s # top
top - 11:30:38 up 40 min, 1 user, load average: 3.06, 2.49, 4.66
Mem: 8168788k total, 2889596k used, 5279192k free, 47792k... (3 Replies)
Hello,
I am working with a perl script that tries to find the average "frequency" in which lines are duplicated. So far I've only managed to find the way to count how many times the lines are repeated, the code is as follows:
perl -ae'
my $filename= $ENV{'i'};
open (FILE, "$filename") or... (10 Replies)
so I've made a shell script that downloads 6 files in succession from a given url, then deletes them. Now I want to time the script, and the average time it uses by running it ~100 times. My problem is tho, how do I store the time it takes for each run through of the script? I know time writes to... (3 Replies)
I am trying to find the minimum maximum and average from one file which has values
Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds.
Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds.
Received message from... (5 Replies)
I want to get CPU average value only (not required user CPU & memory) with each hours on individual date. The sample output is below
| | | User |Memory| User |
Date | Time |CPU %|CPU % | % |Mem % |
03/02/2015|00:00:00| 24.56| 20.66| 89.75| 63.48|... (13 Replies)
Discussion started by: Saravanan_0074
13 Replies
LEARN ABOUT CENTOS
ldns-dpa
dpa(1) General Commands Manual dpa(1)NAME
dpa - DNS Packet Analyzer. Analyze DNS packets in ip trace files
SYNOPSIS
dpa [ OPTION ] TRACEFILE
DESCRIPTION
dpa is used to analyze dns packets in trace files. It has 3 main options: count, filter, and count uniques (i.e. count all different
occurences).
OPTIONS -c expressionlist
Count occurrences of matching expressions
-f expression
Filter: only process packets that match the expression
-h Show usage
-p Show the total number of correct DNS packets, and percentage of -u and -c values (of the total of matching on the -f filter. if no
filter is given, percentages are on all correct dns packets)
-of file
Write all packets that match the -f flag to file, as pcap data.
-ofh file
Write all packets that match the -f flag to file, in hexadecimal format, readable by drill.
-s Show possible match names
-s matchname
show possible match operators and values for name
-sf Only evaluate packets (in representation format) that match the -f filter. If no -f was given, evaluate all correct dns packets.
-u matchnamelist
Count every occurence of every value of the matchname (for instance, count all packetsizes, see EXAMPLES in ldns-dpa(1) ).
-ua For every matchname in -u, show the average value of all matches. Behaviour for match types that do not have an integer value is
undefined.
-uac For every matchname in -u, show the average number of times this value was encountered.
-um number
Only show the results from -u for values that occurred more than <number> times.
-v level
Set verbosity to level (1-5, 5 being the highest). Mostly used for debugging.
-notip file
Write packets that were not recognized as IP packets to file (as pcap data).
-baddns file
Write dns packets that were too mangled to parse to file (as pcap data).
-version
Show version and exit
LIST AND MATCHES
A <matchnamelist> is a comma separated list of match names (use -s to see possible match names). A <expressionlist> is a comma separated
list of expressions.
An expression has the following form: <expr>: (<expr>)
<expr> | <expr>
<expr> & <expr>
<match>
<match>: <matchname> <operator> <value>
<operator>: = equal to <value> != not equal to <value> > greater than <value> < lesser than <value>
>= greater than or equal to <value> <= lesser than or equal to <value> ~= contains <value>
See the -s option for possible matchnames, operators and values.
EXAMPLES
ldns-dpa -u packetsize -p test.tr
Count all different packetsizes in test.tr and show the precentages.
ldns-dpa -f "edns=1&qr=0" -of edns.tr test.tr
Filter out all edns enable queries in test.tr and put them in edns.tr
ldns-dpa -f edns=1 -c tc=1 -u rcode test.tr
For all edns packets, count the number of truncated packets and all their rcodes in test.tr.
ldns-dpa -c tc=1,qr=0,qr=1,opcode=QUERY test.tr
For all packets, count the number of truncated packets, the number of packets with qr=0, the number of packets with qr=1 and the
number of queries in test.tr.
ldns-dpa -u packetsize -ua test.tr
Show all packet sizes and the average packet size per packet.
ldns-dpa -u srcaddress -uac test.tr
Show all packet source addresses and the average number of packets sent from this address.
sudo tcpdump -i eth0 -s 0 -U -w - port 53 | ldns-dpa -f qr=0 -sf
Print all query packets seen on the specified interface.
AUTHOR
Written by Jelte Jansen for NLnetLabs.
REPORTING BUGS
Report bugs to <jelte@nlnetlabs.nl>.
COPYRIGHT
Copyright (C) 2005 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR-
POSE.
1 Nov 2005 dpa(1)