Sponsored Content
Top Forums Shell Programming and Scripting Need Help with awk and arrays Post 302166358 by otheus on Monday 11th of February 2008 05:31:18 PM
Old 02-11-2008
Quote:
Originally Posted by fusionX
I only get this output with your code:Smilie
busiest day: -1 hits 1 times.
First, finish filling out the months table in the BEGIN block. Second, the time-zone doesn't correctly get registered. Replace lt[8] with $5. Third, feel free to insert "print" statements to get some debugging output. I saw only a few lines of the log file, and I tested my code only against those liens.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Two or more arrays in Awk

Hi All, I have been working on awk and arrays. I have this small script: cat maillog*|awk -F: '$2=="SMTP-Accept" && $5~/string/ {lastdate=substr($1,1,8); internaluser=$5; v++} END {for (j in v) {print lastdate, v, j}'| sort>> mail.list This gives me the number of mails users are getting. ... (1 Reply)
Discussion started by: nitin
1 Replies

2. Shell Programming and Scripting

arrays in awk???

Been struggling with a problem, I have been trying to do this in awk, but am unable to figure this out, I think arrays have to be used, but unsure how to accomplish this. I have a input file that looks like this: 141;ny;y;g 789;ct;e;e 23;ny;n;u 45;nj;e;u 216;ny;y;u 7;ny;e;e 1456;ny;e;g... (3 Replies)
Discussion started by: craigsky
3 Replies

3. Shell Programming and Scripting

awk arrays

Guys, OK so i have been trying figure this all all day, i guess its a pretty easy way to do it. Right, so i have to column of data which i have gotten from one huge piece of data. What i would like to do is to put both of these into one array using awk. Is this possible?? If so could... (1 Reply)
Discussion started by: imonthejazz
1 Replies

4. Shell Programming and Scripting

Arrays in awk

Hi, I've written the following code to manipulate the first 40 lines of a data file into my desired order: #!/bin/awk -f { if (NR<=(4)){ a=a$0" "} else { if ((NR >= (5)) && (NR <= (13))) { b=b$0" " } else {if ((NR >= (14)) && (NR <= (25))){ c=c$0" "} ... (5 Replies)
Discussion started by: catwoman
5 Replies

5. Shell Programming and Scripting

awk arrays can do this better - but how?

Hi, I have spent the afternoon trawling Google, Unix.com and Unix in a Nutshell for information on how awk arrays work, and I'm not really getting too far. I ahve a batch of code that I am pretty sure can be better managed using awk, but I'm not sure how to use awk arrays to do what I'm... (1 Reply)
Discussion started by: littleIdiot
1 Replies

6. Shell Programming and Scripting

arrays in awk

Hi, I have the following data in a file for example: Name="Fred","Bob","Peterson","Susan","Weseley" Age="24","30","28","23","45" Study="English","Engineering","Physics","Maths","Psychology" Code="0","0","1","1","0" Name="Fred2","Bob2","Peterson2","Susan2","Weseley2"... (14 Replies)
Discussion started by: james2009
14 Replies

7. UNIX for Dummies Questions & Answers

awk arrays

Hi Can someone please explain the logic of awk arrays. I have been doing some reading but I dont understand this: #!/usr/bin/gawk -f { arr++; } end { for(i in arr) { print arr,i } } As I understand arr refs the arrays index, so while $2 is a string that cant... (2 Replies)
Discussion started by: chronics
2 Replies

8. Shell Programming and Scripting

help in awk arrays!

Hi, buddies I am new to shell scripting and trying to solve a problem. I read about arrays in awk that they are quite powerful and are associative in nature. Awk Gurus Please help! I have a file: Id1 pp1 0t4 pp8 xy2 Id43 009y black Id6 red xy2 Id12 new pp1 black I have... (5 Replies)
Discussion started by: geli21
5 Replies

9. Shell Programming and Scripting

Using arrays with awk

I'm a little stuck and would be grateful of some advice! I have three files, two of which contain reference data that I want to add to a line of output in the third file. I can't seem to get awk to print array contents as I would expect. The input files are: # Input file AAA,OAA,0313... (2 Replies)
Discussion started by: maccas17
2 Replies

10. Shell Programming and Scripting

awk Arrays

So I'm back once again beating my head off a wall trying to figure out how to get this to work. My end goal is to take input such as what's below, which will be capture in real time with a tail -f from a file or piped output from another command: ... (5 Replies)
Discussion started by: ShadowBlade72
5 Replies
PRIVOXY-LOG-PARSER(1)					User Contributed Perl Documentation				     PRIVOXY-LOG-PARSER(1)

NAME
privoxy-log-parser - A parser and syntax-highlighter for Privoxy log messages SYNOPSIS
privoxy-log-parser [--accept-unknown-messages] [--html-output] [--no-msecs] [--no-syntax-higlighting] [--statistics] [--shorten-thread-ids] [--show-ineffective-filters] [--url-statistics-threshold] [--version] DESCRIPTION
privoxy-log-parser reads Privoxy log messages and - syntax-highlights recognized lines, - reformats some of them for easier comprehension, - filters out less useful messages, and - (in some cases) calculates additional information, like the compression ratio or how a filter affected the content size. With privoxy-log-parser you should be able to increase Privoxy's log level without getting confused by the resulting amount of output. For example for "debug 64" privoxy-log-parser will (by default) only show messages that affect the content. If a filter doesn't cause any hits, privoxy-log-parser will hide the "filter foo caused 0 hits" message. OPTIONS
[--accept-unknown-messages] Don't print warnings in case of unknown messages, just don't highlight them. [--host-statistics-threshold] Only show the request count for a host if it's above or equal to the given threshold. If the threshold is 0, host statistics are disabled. [--html-output] Use HTML and CSS for the syntax highlighting. If this option is omitted, ANSI escape sequences are used unless --no-syntax-highlighting is active. This option is only intended to make embedding log excerpts in web pages easier. It does not escape any input! [--no-msecs] Don't expect milisecond resolution [--no-syntax-highlighting] Disable syntax-highlighting. Useful when the filtered output is piped into less in which case the ANSI control codes don't work, or if the terminal itself doesn't support the control codes. [--shorten-thread-ids] Shorten the thread ids to a three-digit decimal number. Note that the mapping from thread ids to shortened ids is created at run-time and thus varies with the input. [--show-ineffective-filters] Don't suppress log lines for filters that didn't modify the content. [--statistics] Gather various statistics instead of syntax highlighting log messages. This is an experimental feature, if the results look wrong they very well might be. Also note that the results are pretty much guaranteed to be incorrect if Privoxy and Privoxy-Log-Parser aren't in sync. [--unbreak-lines-only] Tries to fix lines that got messed up by a broken or interestingly configured mail client and thus are no longer recognized properly. Only fixes some breakage, but may be good enough or at least better than nothing. Doesn't do anything else, so you probably want to pipe the output into privoxy-log-parser again. [--url-statistics-threshold] Only show the request count for a resource if it's above or equal to the given threshold. If the threshold is 0, URL statistics are disabled. [--version] Print version and exit. EXAMPLES
To monitor a log file: tail -F /usr/jails/privoxy-jail/var/log/privoxy/privoxy.log | privoxy-log-parser Replace '-F' with '-f' if your tail implementation lacks '-F' support or if the log won't get rotated anyway. The log file location depends on your system (Doh!). To monitor Privoxy without having it write to a log file: privoxy --no-daemon /usr/jails/privoxy-jail/usr/local/etc/privoxy/config 2>&1 | privoxy-log-parser Again, the config file location depends on your system. Output redirection depends on your shell, the above works with bourne shells. To read a processed Privoxy log file from top to bottom, letting the content scroll by slightly faster than you can read: privoxy-log-parser < /usr/jails/privoxy-jail/var/log/privoxy/privoxy.log This is probably only useful to fill screens in the background of haxor movies. CAVEATS
Syntax highlighting with ANSI escape sequences will look strange if your background color isn't black. Some messages aren't recognized yet and will not be fully highlighted. privoxy-log-parser is developed with Privoxy 3.0.7 or later in mind, using earlier Privoxy versions will probably result in an increased amount of unrecognized log lines. Privoxy's log files tend to be rather large. If you use HTML highlighting some browsers can't handle them, get confused and will eventually crash because of segmentation faults or unexpected exceptions. This is a problem in the browser and not privoxy-log-parser's fault. BUGS
Many settings can't be controlled through command line options yet. SEE ALSO
privoxy(1) AUTHOR
Fabian Keil <fk@fabiankeil.de> perl v5.14.2 2012-05-18 PRIVOXY-LOG-PARSER(1)
All times are GMT -4. The time now is 07:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy