Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I retreive date info from the data file header

Status
Not open for further replies.

rchowd2

Technical User
Jan 4, 2005
8
0
0
US
I have a data file which contains the following header record in one ine:
--------------------------------------
HEADER 2/16/0515.03.30TIO01676CMS.TST.IWUNV676.IO01 416360 ---------------------------

I am having difficulty just to retreive the date information (ex: 2/16/05). I tried to use Awk command but wasn't too succesful. Any advise on how can I retreive the date info from the file header.

Thanks,

Russel
 

nawk -f rc.awk dataFile

rc.awk:
Code:
BEGIN {
  FS="[ ]*|[.]"
}
FNR==1 {
   print substr($2, 1, length($2)-2)
}

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Vlad, may i ask why <this and that>, and not [ .]* - I have seen a few posts of you doing the like.

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
to be honest with you I don't know - I think it's a matter of habit. And I also think that it makes it easier for me personally to visually separate two separators [no pun intended].

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I see, well i was thinking it was the habit.. my habit went over to be performant w/o |'s where they arent needed. Quite cool marker tho.

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top