I'd like to be able to specify a column, say H2, and then have information about that column printed. The information I am interested in is the number of entries under H2 (ignoring any -- entries) and then the min/max and finally the average. I am completely new to awk and so any help would be appreciated.
I think this will work. Column number and the header text are supplied as variables so it should be flexible.
Code:
awk '
$(col) == header { #reset things each time we see the desired header
v = 0;
sum = 0;
min = 9e9;
max = -9e9;
next;
}
$(col) != "--" {
v++;
sum += $(col);
if( $(col) > max )
max = $(col);
if( $(col) < min )
min = $(col);
}
END {
printf( "values=%d min=%d max=%d mean=%d\n", v, min, max, sum/v );
}
' col=2 header="H2" input-file >output-file
I have an interactive script which works terrific at processing a folder of unsorted files into new directories.
I am wondering how I could modify my script so that( upon execution) it provides an additional labelled summary file on my desktop that lists all of the files in each directory that... (4 Replies)
I have a data file similar to this (but many millions of lines long). You can assume that it is totally unsorted but has no duplicate rows.
Date ,Tool_Type ,Tool_ID ,Time_Used
3/13/2014,Screwdriver,Screwdriver02, 6
3/13/2014,Screwdriver,Screwdriver02,20... (2 Replies)
Displaying information using awk
Hey guys, i am using awk to display my information in a certain order.
Database : Persia:42:John
France:50:Mabel
Persia:50:Rach
Germany:60:JohnMy expected output is :
... (25 Replies)
Hi
I have a very structured file consisting of multiple lines as follows:
3752 AVAILABLE 06/24/2009 FFFF 000000 0000 0000
3753 TRADITION (ASIA) LTD TACB 008329 0000 0000
3754 WACHOVIA CONVS/PRFDS WBCP 001099 0000 0000
3755 AVAILABLE 05/12/2009 FFFF 000000 0000 0000
3756... (3 Replies)
Folks,
I have multiple files in a folder containing some information (there is around 100 of them). What I would like to do would be able to import some of the information into a summary text file so that it will be easier to read a glance.
The name of the files all start with the naming... (4 Replies)