So, I need to do some summing. I have an Apache log file with the following as a typical line:
Now, what I'd like to do is a per-minute sum. So, I can have awk tell me the individual minutes, preserving the dates(since this is a multi-day log):
I can have it sum based on a single date:
...but what I'd really like to do is generate a new sum of $10 for each different instance of substr($4,2,17). This can be done by looping-- a foreach/for, etc-- and feeding minutes into the awk one at a time. The problem is that this method reads the file completely every pass through the loop. Ideally, I'd like to do it with a single pass. Any suggestions?
I want to find the top N entries for a certain field based on the values of another field.
For example if N=3, we want the 3 best values for each entry:
Entry1 ||| 100
Entry1 ||| 95
Entry1 ||| 30
Entry1 ||| 80
Entry1 ||| 50
Entry2 ||| 40
Entry2 ||| 20
Entry2 ||| 10
Entry2 ||| 50... (1 Reply)
Hi, all
I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes.
sample input:
for this line, 5 fields are supposed to be extracted, they... (8 Replies)
First, thanks for the help in previous posts... couldn't have gotten where I am now without it!
So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following:
If $1... (4 Replies)
I am trying to parse the input in awk to include the |gc= in $4 but am not able to. The below is close:
awk so far:
awk '{sub(/\|]+]++/, ""); print }' input.txt Input
chr1 955543 955763 AGRN-6|pr=2|gc=75 0 +
chr1 957571 957852 AGRN-7|pr=3|gc=61.2 0 +
chr1 970621 ... (7 Replies)
We have a csv file as mentioned below and the requirement is to change the date format in file as mentioned below.
Current file (file.csv)
----------------------
empname,date_of_join,dept,date_of_resignation
ram,08/09/2015,sales,21/06/2016
"akash,sahu",08/10/2015,IT,21/07/2016
... (6 Replies)
In the tab-delimeted input file below I am trying to use awk to update the value in $2 if TYPE=ins in bold, by adding the value of
HRUN= in italics. In the below since in line 1 TYPE=ins the 117282541 value in $2 has 6 added because that is the value of HRUN=.
Hopefully the awk is a start but I... (2 Replies)
I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines.
If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
In the awk below I am trying to set/update the value of $14 in file2 in
bold, using the matching NM_ in $12 or $9 in file2
with the NM_ in $2 of file1.
The lengths of $9 and $12 can be variable but what is consistent is the start pattern
will always be NM_ and the end pattern is always ;... (2 Replies)
Hi Team,
In the below input file, if I have the value 23,24,25 then for those records 1st field value should get updated from "a" to "b". I also want to pass these values in file as input as it can be done dynamically. Tried awk commands but not getting desired output.Using SunOS 5.10 version.... (14 Replies)
Hi,
So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
LEARN ABOUT DEBIAN
stda
STDA(1) User Commands STDA(1)NAME
stda - Simple Tools for Data Analysis (STDA)
DESCRIPTION
STDA includes some primary tools for data analysis. You can evaluate sums, averages, integrals, derivatives, histograms or probability dis-
tribution functions of 1-d data, and eventually plot the results. The programs are stand-alone tools (supporting the standard UNIX input
and output pipelines) intended for data processing from the command line. It should be noted that all but one of the scripts use awk and
core system utilities. For plotting you have to install Gnuplot (see http://gnuplot.info) since 'muplot' is a wrapper around it. In sum-
mary, the package provides utilities for straightforward analysis of data series where a complex analytical approach is not needed and
where an ultimate numerical precision with floating-point numbers is not critical. Some general examples of application cases include eval-
uating usage statistics from server logfiles, determining a response time distribution from a series of queries to a [remote] service, pro-
ducing a plot from multiple data files, etc.
This software should be considered as an open project to be extended with new command-line driven utilities helpful for performing common
data analysis tasks. Any contributions and suggestions are welcome.
Following programs are included in the distribution:
* maphimbu - histogram builder for 1-d numerical and text data
* mintegrate - average/sum/integral/derivative of 1-d numerical data
* mmval - find minimum and maximum value in a data set
* muplot - plot a multi-curve figure from multiple data by using Gnuplot
* nnum - produce a series of equally separated integers or floats
* prefield - prepare input file for 'muplot' to plot 2-d fields by arrows
EXAMPLES
- Evaluate the current apache2 logfile and make an unique list of the hostnames (respectively ip-addresses) sorted by the total number of
their http requests:
maphimbu -rs2 /var/log/apache2/access.log
- On a X terminal plot the probability function and the cumulative distribution function of a sin(x) data sample:
nnum -3.14159 3.14159 0.00001 %.6g |awk '{ print $1, sin($1) }' | maphimbu -d0.01 -x2 -ns1 |mintegrate -d0.01 -x1 -y3-S |muplot
lp - 1:3,4
COPYRIGHT
Copyright (C) 2009, 2011-2012 Dimitar Ivanov <dimitar.ivanov@mirendom.net>
License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
stda 1.1.1 February 2012 STDA(1)