If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Validate Header of file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-26-04, 13:35
varun_751980 varun_751980 is offline
Registered User
 
Join Date: Nov 2003
Location: India
Posts: 114
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
Reply With Quote
  #2 (permalink)  
Old 07-26-04, 14:00
vgersh99 vgersh99 is offline
Registered User
 
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> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 07-26-04, 23:46
varun_751980 varun_751980 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-27-04, 05:00
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
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}$"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On