Find the answer to your Linux question:
Results 1 to 3 of 3
Hey forum, I have a question which is driving me crazy, I have a Apache web log file and I am trying to extract a string of text out of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    3

    Newbie has a grep problem


    Hey forum,
    I have a question which is driving me crazy,
    I have a Apache web log file and I am trying to extract a string of text out of it . This is the piece of text i have copied from the log.

    I am trying to extract from ?hl to "; and print out the entries to a file

    /search?hl=en&q=frequently+used+unix+aliases&btnG=Google+Sea rch"; "Mozilla/4.0

    Should i be using a grep command to do this?

    Here is what I had been trying
    grep '\<?hl+eta\>' logs.txt


    any help is really great

    Many thanks

    Kaly

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    Is this what you want?
    Code:
    egrep -o '\?hl.*\";' logs.txt
    On a related note, apachegrep might be of interest also:
    apachegrep
    Manpage of apachegrep
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    3
    Thanks a million Irithori, much appreciated it worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •