Find the answer to your Linux question:
Results 1 to 2 of 2
i get messages log on redhat Dec 10 16:02:24 NAX-FC8 kernel: LOG HTTPS IN=eth0 OUT=eth1 SRC=65.54.165.179 DST=172.168.1.200 LEN=361 TOS=0x00 PREC=0x00 TTL=109 ID=55863 DF PROTO=TCP SPT=443 DPT=49979 WINDOW=65379 RES=0x00 ACK PSH ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84

    how to filter text want to see with awk.!!

    i get messages log on redhat

    Dec 10 16:02:24 NAX-FC8 kernel: LOG HTTPS IN=eth0 OUT=eth1 SRC=65.54.165.179 DST=172.168.1.200 LEN=361 TOS=0x00 PREC=0x00 TTL=109 ID=55863 DF PROTO=TCP SPT=443 DPT=49979 WINDOW=65379 RES=0x00 ACK PSH URGP=0
    Dec 10 16:02:24 NAX-FC8 kernel: LOG HTTPS IN=eth1 OUT=eth0 SRC=172.168.1.200 DST=65.54.165.179 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=16632 DF PROTO=TCP SPT=49979 DPT=443 WINDOW=16660 RES=0x00 ACK URGP=0
    Dec 10 16:02:24 NAX-FC8 kernel: LOG HTTPS IN=eth1 OUT=eth0 SRC=172.168.1.200 DST=65.54.165.179 LEN=222 TOS=0x00 PREC=0x00 TTL=127 ID=16633 DF PROTO=TCP SPT=49979 DPT=443 WINDOW=16660 RES=0x00 ACK PSH URGP=0
    Dec 10 16:02:25 NAX-FC8 kernel: LOG HTTPS IN=eth0 OUT=eth1 SRC=65.54.165.179 DST=172.168.1.200 LEN=83 TOS=0x00 PREC=0x00 TTL=109 ID=56489 DF PROTO=TCP SPT=443 DPT=49979 WINDOW=65197 RES=0x00 ACK PSH URGP=0

    and i want to "cat messages" and filter and show text i want only.

    DATE TIME
    IN
    OUT
    PROTO
    SRC
    DST


    example

    Dec 10 16:02:25 LOG HTTPS IN=eth0 OUT=eth1 SRC=65.54.165.179 DST=172.168.1.200 PROTO=TCP SPT=443 DPT=49979

    how to use awk,grep for filter it.

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Most modern versions of grep allow you to collect patterns into a file, then use those patterns to filter data files:
    Code:
           -f FILE, --file=FILE
                  Obtain patterns from FILE, one per line.  The  empty  file  con-
                  tains zero patterns, and therefore matches nothing.
    -- excerpt from man grep
    Look over man grep, try it and let us know if you have any problems ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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