Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    India
    Posts
    114

    Unanswered: Validate Header of file

    I want to write a function which would validate the first line of mine file.
    The first line of line is the date format. I can cut it off using head command and then I want to validate the header. The header should be in date format
    ddmmyyyy. I dont want any database intervetion.

    Can experts help me in this regard.

    Regards
    Varun

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    posting a sample imput AND a desired output would be a good start.
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  3. #3
    Join Date
    Nov 2003
    Location
    India
    Posts
    114

    Validating header of file

    I have a file like

    12072004
    111
    222
    333
    444
    555
    5

    This is mine file. The first line is the date in format ddmmyyyyy. Then come the Records and last line is no of records in the file.

    I want to cut the header and verify that it is in desired date format.
    (ddmmyyyy)

    Experts plz help

  4. #4
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    I've just done something similar recently. I wrote the regex below which will validate a date in format ddmmccyy. The only probelm with it is that it assumes February always has 29 days.

    Code:
    head -1 yourFile | grep -E "^(([012][0-9]|3[01])(0[13578]|1[02])|([012][0-9]|30)(0[946]|11)|([01][0-9]|2[0-9])02)20[0-9]{2}$"

Posting Permissions

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