UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 13th, 2003, 05:58 PM
jin jin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 22 jin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
egrep help? (keeping a count)

Hi,

I am a bit new to Unix and am trying to use egrep to give me some results.

I have data in a file "data" that has lines such as this:

0 2 - - [01/Aug/2003:00:01:45 -0700] http://asd.com/bar/blah1
1 3 - - [01/Aug/2003:00:01:45 -0700] http://fgh.com/blah1.html
5 1 - - [01/Aug/2003:00:01:45 -0700] http://blah3.com/b/
4 8 - - [02/Aug/2003:00:01:45 -0700] http://hjk.com/blah3
8 3 - - [02/Aug/2003:00:01:45 -0700] http://lzx.blah3/
9 6 - - [03/Aug/2003:00:01:45 -0700] http://cvb.com/blah4
2 7 - - [04/Sep/2003:00:01:45 -0700] http://bnm.com/blah4
1 9 - - [04/Sep/2003:00:01:45 -0700] http://qwe.com/blah4
..

i need help making a statement(s) that can count how many occurences a specified term appears in the URL (e.g. "blah1") on a specific date. BlahN can appear anywhere in the URL. (Also the first two columns can be any numbers.. not just a single digit.. but i don't think this should affect anything)

For example, if choosing blah1 for the the term and 01/Aug/2003 as the date would return : 2.
Choosing blah 3 for the term and 02/Aug/2003 would return : 2
Choosing blah 3 for the term and 01/Aug/2003 would return : 1
Choosing blah4 for the term and 04/Sep/2003 would return : 2
and so forth.

I am incorporating this in a perl script.. i have gotten the input for the date and term stored already.. i just need help getting a grep statement for this.. or whatever else i need (e.g. "cut") .. is this possible?

any ideas??

thanks!

Reply With Quote
  #2  
Old August 13th, 2003, 06:57 PM
jin jin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 22 jin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wc

it's definitley necessary to use 'wc -l' (i think!) but i'm having trouble..

thx!

Reply With Quote
  #3  
Old August 14th, 2003, 12:05 PM
jin jin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 22 jin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
currently, i have:

cat datafile | grep "$term" | grep "$date" | wc -l

but if there is 1 hit, it returns 0.. for all other cases (i *think* it seems to be working). does anybody know why it returns 0. i have a feeling it's because of the \n -

thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > egrep help? (keeping a count)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap