![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| count occurences of specific character in the file | superprogrammer | HP-UX | 9 | 04-09-2008 11:05 AM |
| Count the number of occurence of perticular word from file | rinku | Shell Programming and Scripting | 40 | 08-10-2007 07:33 PM |
| grep and count no of occurences in every line of a file | srikanthgr1 | Shell Programming and Scripting | 12 | 04-20-2007 09:16 AM |
| How to count no of occurences of a character in a string in UNIX | kamesh83 | UNIX for Advanced & Expert Users | 11 | 03-17-2006 02:39 PM |
| word count showing wrong number of lines | tselvanin | UNIX for Dummies Questions & Answers | 3 | 01-06-2004 11:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
I want to count the number of occurences of say "200" in a file but that file also contains various stuff including dtaes like 2007 or smtg like 200.1 so count i am getting by doing grep -c "word" file is wrong
Please help!!!!! |
|
||||
|
I thought OP was interested in the count of pattern ( that are to be considered as complete patterns ) and not the number of such patterns that might occur in the same line
Well, this is possible. ![]() To make it clear, OP has to publish sample data ![]() |
|
||||
|
cpliterature_23289.esw3c_S.200710260000-2400-0:2007-10-25 23:56:52 72.30.216.103 GET /cpliterature.product.agilent.com/litweb/pdf/5989-4075ZHA.pdf 200 505286 72 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" "-"
cpliterature_23289.esw3c_S.200710260000-2400-0:2007-10-25 23:57:14 74.6.28.142 GET /cpliterature.product.agilent.com/litweb/pdf/81130-91220.pdf 200 2888156 320 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" "-" cpliterature_23289.esw3c_S.200710260000-2400-0:2007-10-26 00:00:03 74.6.19.209 GET /cpliterature.product.agilent.com/litweb/pdf/5988-4969EN.pdf 200 1905042 156 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" "-" My file contains data like given above..... I have to find number of times 200 appears in this file but only that 200 which comes after pdf |
|
|||||
|
this would work in the case that we have, where pattern "pdf 200" exists at only one place on a line. I was under impression that the pattern may exist multiple times on the same line.
My solution was aimed at that, which would give the exact count (grep would give incorrect count, since it counts the number of lines on which the pattern is found) |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| grep, perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|