Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Check if data is in squid native log format

How to write a script to check a line from a file to confirm that the data in file is in squid native log file format.
Providing the followings:
1) data_file (sample data)
1086670800.875 79 TCP_MISS/200 21326 GET http://www.ato.gov.au/common/javascript/iemenus.js - DIRECT/www.ato.gov.au text/html

2) squid native file format:
Thx all,
1 Solution
Hmm, let's see.  You could use some kind of regex package, and compile a regular expression that accepts that squid format.

For example: grep -ve"^[0-9]*\.[0-9]* [0-9]* [^ ]* [^/]*/[0-9]* [0-9]* [^ ]* [^ ]*" <file> might work to show all lines that are not in this format.
(Assuming I parsed that correctly)

Of course, you could put in additional restrictions, if you know for sure for example that the URL is of the form <something>://<something> you could put that in.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now