LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2016, 02:46 PM   #16
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled

I put in the wrong code for you sorry
Code:
grep -o Firefox/[0-9.]* example.log | sort | uniq -c
for some reason when I did the grep "Firefox/" it wouldn't work for me.

it came out
86 Firefox/1.5.0.12
570 Firefox/3.0.11
1360 Firefox/3.0.19
84 Firefox/3.5.7
1985 Firefox/3.5.9
17 Firefox/3.6.2
3769 Firefox/3.6.3
 
Old 02-26-2016, 02:53 PM   #17
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
I put in the wrong code for you sorry
Code:
grep -o Firefox/[0-9.]* example.log | sort | uniq -c
for some reason when I did the grep "Firefox/" it wouldn't work for me.

it came out
86 Firefox/1.5.0.12
570 Firefox/3.0.11
1360 Firefox/3.0.19
84 Firefox/3.5.7
1985 Firefox/3.5.9
17 Firefox/3.6.2
3769 Firefox/3.6.3
Nice one. One small point is that the dot in the square brackets is a special character meaning "any character". You should put a backslash \ before it to indicate that you are looking for an actual dot.

Also, you should place the whole search string in double quotes to be on the safe side.

Before we touch MSIE, any time that you use a grep, you have to think "what data may I have missed out"? You have to check that you are catching everything.

So, I suggest that you run both:

Code:
grep -c -o "Firefox/[0-9\.]*" example.log
and

Code:
grep -c -o "Firefox" example.log
to confirm that you have picked up all the Firefox lines.
 
Old 02-26-2016, 02:59 PM   #18
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
okay so the numbers in front of the Firefox and version will add up to the total number of Firefox
both codes came up with 7871 that matches.
 
Old 02-26-2016, 03:01 PM   #19
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
okay so the numbers in front of the Firefox and version will add up to the total number of Firefox
both codes came up with 7871 that matches.
That was the answer I was hoping for.

Otherwise you would have had to search for the ones you were missing, and then change the grep regular expression to make sure you picked them up.

Right, can you go through the same steps, including that last check, for MSIE?
 
Old 02-26-2016, 03:07 PM   #20
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
I am trying right now
 
Old 02-26-2016, 03:10 PM   #21
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
I am trying right now
There is no hurry. You've been very patient.

If you could also cut and paste an example of one of the logfile entries with MSIE then that would be great, as the original example you gave only had Firefox lines.
 
Old 02-26-2016, 03:15 PM   #22
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
192.168.149.163 user137 [08/May/2010:09:51:30] "GET / HTTP/1.1" "http://www.example.com/Ticket/Display.html?id=236821&results=54058c6bb77364e805a28b05cf401789" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 1.0.3705"

192.168.149.163 user15 [08/May/2010:09:51:13] "GET /Ticket/Display.html?id=236821&results=54058c6bb77364e805a28b05cf401789 HTTP/1.1" "http://www.example.com/Ticket/Update.html?Action=Comment&id=236821" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 1.0.3705"

192.168.149.163 user101 [08/May/2010:09:51:12] "POST /Ticket/Update.html HTTP/1.1" "http://www.example.com/Ticket/Update.html?Action=Comment&id=236821" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 1.0.3705"

192.168.170.132 user195 [08/May/2010:09:43:52] "GET /index.html HTTP/1.1" "http://www.example.com/Ticket/Display.html?id=238759&results=16189b033b19ffdba5b07b0dddc11b85" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"

192.168.170.132 user43 [08/May/2010:09:43:52] "GET / HTTP/1.1" "http://www.example.com/Ticket/Display.html?id=238759&results=16189b033b19ffdba5b07b0dddc11b85" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"

192.168.170.132 user38 [08/May/2010:09:43:41] "GET /Ticket/Display.html?id=238759&results=16189b033b19ffdba5b07b0dddc11b85 HTTP/1.1" "http://www.example.com/Ticket/Update.html?Action=Comment&id=238759" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)"

See this is different I can get the MSIE alone but do I have to get rid of the () first?
 
Old 02-26-2016, 03:26 PM   #23
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
See this is different I can get the MSIE alone but do I have to get rid of the () first?
Thanks. You don't need to "get rid of" anything, because all you're doing is searching for text inside a string. You just grab what you want and ignore the rest.

In this case, focus on what you want i.e. "MSIE" and the version number e.g. "MSIE 7.0". But notice that it is different from the Firefox one.

In English, you want to search for MSIE, followed by a space, followed by zero or more digits or dots.

Over to you to write that grep command. It's not much different from the Firefox one.

P.S. When you paste output, it's best to enclose it in <CODE> tags, even though it isn't technically code. It will stop parts of it being interpreted as smiley faces for example.
 
Old 02-26-2016, 03:51 PM   #24
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
okay so I got
Code:
grep -o MSIE\.[0-9]\.[0-9]* example.log | sort | uniq -c
and the out come was:
175564 MSIE 6.0
125834 MSIE 7.0
15263 MSIE 8.0

Okay so I redid the code so I could get the whole 6.0 instead of just 6

Last edited by reginah72; 02-26-2016 at 03:57 PM.
 
Old 02-26-2016, 03:57 PM   #25
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
okay so I got
Code:
grep -o MSIE\.[0-9]* example.log | sort | uniq -c
and the out come was:
175564 MSIE 6
125834 MSIE 7
15263 MSIE 8

I need something before the example.log to put in the .0 right?
First of all, you really need to enclose the search term in double quotes (I'm not going to tell you a fourth time ).

Secondly, your grep is searching for MSIE followed by a dot followed by zero or more digits - that's not what you should be searching for (see my last post).

Don't worry, try it again.

Last edited by hydrurga; 02-26-2016 at 03:58 PM.
 
Old 02-26-2016, 03:59 PM   #26
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
Code:
grep -o "MSIE\.[0-9]\.[0-9]*" example.log | sort | uniq -c
fixed it
 
Old 02-26-2016, 04:06 PM   #27
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
Code:
grep -o "MSIE\.[0-9]\.[0-9]*" example.log | sort | uniq -c
fixed it
Ok, it's getting late and we've been working on this for a fair while, so this one's mine:

Code:
grep -o "MSIE [0-9\.]*" example.log | sort | uniq -c
Do you see how that follows the English of "search for MSIE, followed by a space, followed by zero or more digits or dots"?

It's always useful to think of things in your native language before you turn it into computer language.

Right, test it out, and also ensure that you're picking up all the MSIE's, using a modified version of the test I showed you earlier for Firefox.

We're almost there. Thanks for hanging on in there.
 
Old 02-26-2016, 04:18 PM   #28
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
oh okay I see that now mine worked too but yours is shorter and yes it worked for me

so I have one more the number of people using any other browser

and before I forget THANK YOU THANK YOU I was ready to give up completely and fail the class.

Last edited by reginah72; 02-26-2016 at 04:19 PM.
 
Old 02-26-2016, 04:19 PM   #29
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870Reputation: 2870
Quote:
Originally Posted by reginah72 View Post
oh okay I see that now mine worked too but yours is shorter and yes it worked for me
Great, so the only thing remaining is to determine how many people didn't use either Firefox or MSIE, yes?
 
Old 02-26-2016, 04:21 PM   #30
reginah72
LQ Newbie
 
Registered: Feb 2016
Posts: 16

Original Poster
Rep: Reputation: Disabled
yes
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with getting browser statistics reginah72 Linux - Newbie 2 02-26-2016 07:30 PM
how to check browser log files on centos 5.3 mohanj.linux Linux - Newbie 3 03-27-2013 03:15 AM
Squid statistics via browser - connection aborted noigan *BSD 3 12-29-2010 10:07 AM
Apache Browser Log Files soulestream Linux - Software 1 12-14-2005 03:59 AM
Are there any browser statistics for LQ? MartinN LQ Suggestions & Feedback 3 09-21-2004 09:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration