starlite79
Technical User
Hi there.
I would like to have awk read a file with web stats and print out those lines that had 100 or more hits in a given month.
Here is my code:
The problem is, I think, that the field separator is not defined properly. When I look at the file, it has 5 columns, but they are separated by different amounts of spaces. Right now the only thing that is working correctly is that the "pipe" metacharacter is being replaced by a blank.
At the command line, I type awk -f program oldfile >> newfile
Attached is a piece of the old file I am trying to work with. The columns are %Requests, %Bytes, Bytes Sent, Requests, Archive Section. Can someone offer some assistance?
0.13 0.02 853220 361 | /data.html
0.12 0.02 675071 340 | /info.html
0.02 0.01 460273 45 | /xy.gif
0.01 0.01 268199 20 | /t.gif
I would like to have awk read a file with web stats and print out those lines that had 100 or more hits in a given month.
Here is my code:
Code:
#!/usr/bin/awk
# This awk program reads web statistics with five columns and returns
# information on which html and gif files received 100 or more hits
# in a particular month.
BEGIN {
FS = "[ \t]+" # make any number of tabs,
# and spaces the field separator
}
sub(/\|/, "")
$4 >= 100 { print $0
}
The problem is, I think, that the field separator is not defined properly. When I look at the file, it has 5 columns, but they are separated by different amounts of spaces. Right now the only thing that is working correctly is that the "pipe" metacharacter is being replaced by a blank.
At the command line, I type awk -f program oldfile >> newfile
Attached is a piece of the old file I am trying to work with. The columns are %Requests, %Bytes, Bytes Sent, Requests, Archive Section. Can someone offer some assistance?
0.13 0.02 853220 361 | /data.html
0.12 0.02 675071 340 | /info.html
0.02 0.01 460273 45 | /xy.gif
0.01 0.01 268199 20 | /t.gif