1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Rep Power

    Help required in validating a pipe delimited file using shell script

    Dear All,

    I have a pipe delimited file which contains the header and then the data.

    I have a requirement which needs that the value in the date columns hroughout the file be checked for a particular format as DDMMYYYY.

    The problem i'm facing in is building up the logic as to how can i scan all the records in the file when i don't exactly know which column's can be the date column's.

    Need your help urgently.

    Header: Amount|Date01|Date02|Curr|Date05
    Sample Data: 260.00|12062012|12062012|INR|12062012
  2. #2
  3. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Rep Power
    If you do not know which columns will include a date you wish to validate you are on a hiding to nothing from the start.
    Assuming that you will know which columns should be dates you could do this in a few ways - using awk -F\| and having a validation function in the awk script (so you don't have to repeat code) would be a favourite.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo