The server is up and running. Here is the output. It still didn't create 2nd file.
+ dev=/biddf/ab6498/dev/ctl
+ cd /biddf/ab6498/dev/ctl
+ echo /biddf/ab6498/dev/ctl
/biddf/ab6498/dev/ctl
+ + date +%Y%m%d
files=CARE01_DLY_???_20060721
+ echo CARE01_DLY_AUS_20060721 CARE01_DLY_MKT_20060721
CARE01_DLY_AUS_20060721 CARE01_DLY_MKT_20060721
+ awk {data[FNR] = $0; out=FILENAME "_new"; file[FNR]=out;} END { if (
FNR - 2 == $1) { for ( i=2 ; i < NR; i++ ) { print data[i] > file[i]}
close(file[i])}else { print "error"} } CARE01_DLY_AUS_20060721
CARE01_DLY_MKT_20060721
awk: A print or getline function must have a file name.
The input line number is 5. The file is CARE01_DLY_MKT_20060721.
The source line number is 1.
looks like you missed a couple of changes...the ones in bold should be NR not FNR.
You are great man. It's working. But only thing is that i had two files like this:
CARE01_DLY_MKT_20060721:
RUN
1
1
2
and another file CARE01_DLY_AUS_20060721
RUN
1
1
42
So in the 2nd file CARE01_DLY_AUS_20060721 the record count doesn't match the data rows. Instead of thruoghing error it created two files like
CARE01_DLY_AUS_20060721_new. It shuold through error even if one file has wrong count. But it created 2 files though.
Changed a good bit, so I'll post a whole script again, however only the awk part has changed, there are a few changes, so please double check you've got them all if you have problems. I have tested this and it does work.
I will try in couple of hours. I really thank you for your great help man. It's all most late night and I will be away from my computer for some time. I will revert back once i run your wonderful script.
I was just wondering if we can make the same script work when we mass the file name as parameter. For eg if we say awksatya.ksh CARE01_DLY the script should check for files for todays date and do the same processing. is this possible with the same script. Kindly suggest.
I am now going to close this thread to prevent it from being posted to again with new questions, as anyone posting to it would be unlikely to find anyone willing to read 62 posts so they could understand the question being asked.