Find the answer to your Linux question:
Results 1 to 6 of 6
Hi guys,i got this problem which is..i need to find those sentences with date inside and extract them out,the input is somehow like this eg: $DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16 11:56:45 SUPER.OPR ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    25

    How to find Date format and extract line??

    Hi guys,i got this problem which is..i need to find those sentences with date inside and extract them out,the input is somehow like this

    eg:
    $DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16 11:56:45 SUPER.OPR \NETS.$Y4CB.#IN
    \NETS.4,246
    F DENIED READ

    Report date range........: 2007-08-01 00:00 to 2007-08-01 23:59
    Subject System...........: *
    Subject Userid...........: *.*
    Subject Login Name.......: *
    Subject Terminal.........: *
    Operation................: *

    so what i need is the one with the date format (yyyy/mm/dd):
    $DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16

    this line will be printed..can this be done using sed or awk????

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Something went wrong see below:

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Try this, it prints the 3th field of the line if the first field match with the regexp:

    Code:
    awk '$1 ~ "\$DATA42.GANTRY2.GA161147" {print $3}' file
    Regards

  4. #4
    Just Joined!
    Join Date
    Sep 2007
    Posts
    25
    Hi Franklin,well..the above code i post is not only the file that i need to find the sentences,so i was wondering that if sed or awk can find all those sentences with data format and extract them?Is there anyway to do it?

  5. #5
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Not really clear for me what you're trying to achieve.
    Can you provide further information e.g. the format of the file and the expected output.

    Regards

  6. #6
    Just Joined!
    Join Date
    Sep 2007
    Posts
    25
    hey franklin,thanks for replying,i found the answer le,but thanks to your previous code also,thanks alot!

Posting Permissions

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