[SOLVED] Need help with log files and browser statistics
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.