get quote enclosed field in a line - Unix

This is a discussion on get quote enclosed field in a line - Unix ; is there a simple way in perl, python, or awk/shell/pipe, that gets the user agent field in a apache log? e.g. the typical line is like this: 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: get quote enclosed field in a line

  1. get quote enclosed field in a line

    is there a simple way in perl, python, or awk/shell/pipe, that gets
    the user agent field in a apache log?

    e.g. the typical line is like this:

    189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
    Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
    "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
    5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
    Firefox/2.0.0.13" "-"

    I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:
    1.8.1.13) Gecko/20080311 Firefox/2.0.0.13".

    Thanks.

    Xah
    xah@xahlee.org
    http://xahlee.org/



  2. Re: get quote enclosed field in a line

    xahlee@gmail.com wrote:
    > is there a simple way in perl, python, or awk/shell/pipe, that gets
    > the user agent field in a apache log?
    >
    > e.g. the typical line is like this:
    >
    > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
    > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
    > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
    > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
    > Firefox/2.0.0.13" "-"
    >
    > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:
    > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13".
    >
    > Thanks.
    >
    > Xah
    > xah@xahlee.org
    > ∑ http://xahlee.org/
    >
    > ☄


    Something like:
    # cut -d '"' -f 6 < httpd-access.log
    ?
    --
    mph

  3. Re: get quote enclosed field in a line

    > xah...@gmail.com wrote:
    > > is there a simple way in perl, python, or awk/shell/pipe, that gets
    > > the user agent field in a apache log?


    > Something like:
    > # cut -d '"' -f 6 < httpd-access.log
    > ?
    > --
    > mph


    Doesn't it feel like autosplit mode never gets any run time?

    perl -laF'"' -ne'print $F[5]' access_log


  4. Re: get quote enclosed field in a line

    xahlee@gmail.com wrote:
    > is there a simple way in perl, python, or awk/shell/pipe, that gets
    > the user agent field in a apache log?
    >
    > e.g. the typical line is like this:
    >
    > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
    > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
    > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
    > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
    > Firefox/2.0.0.13" "-"
    >
    > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:
    > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13".
    >
    > Thanks.
    >
    > Xah
    > xah@xahlee.org
    > ∑ http://xahlee.org/
    >
    > ☄


    awk -F\" '{print $6}' httpd-access.log
    awk -F\" 'NF>6{print $6}' httpd-access.log

    --
    Michael Tosch @ hp : com

+ Reply to Thread