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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header Record Question

Status
Not open for further replies.

navink123

Programmer
Sep 2, 2003
21
US
Hi Guys,
I need to display the following information in a file. This file is going to contain only one record which is displayed by running query on another file(2nd file). DATE is the date 2nd file created, TIME: time 2nd file created, RECCNT : # of records in 2nd file. BLANK: 17 black characters.

------------------------------------------------------
Field Length Format/Description
------------------------------------------------------
DATE: 8 CCYYMMDD
TIME: 6 HHMMSS
RECCNT: 9 Number of records in the file
Blank: 17 Blank Characters.

Can anybody help me with how this can be done.

Thanks,
N
 
RECCNT=`cat file2 | wc -l`
Blank=`tr -dc ' ' <file2 | wc -c`
For DATE and TIME you're in trouble as no *nix flavor keeps trace of creation date.
Note: Hope not a homework ...

Hope This Help
PH.
 
It is not an homework :).

I am an oracle developer trying to work on unix platform. The data file(2nd file)is being generated by an oracle query. But while ftping this data file to the target system we need to ftp another file also which is going to contain a header record with the information about data file.

You said that no Unix flavor keeps trace of creation date. But date and time is displayed when we do a listing right.
Is there any way we can list the file and pull the date and time ?

I have the logic but am not too comfortable with the syntax as I am new to UNIX.

Thanks,
N
 
For last modification:
eval `perl -e '
($ss,$mn,$hh,$dd,$mm,$yy,$wd,$yd,$dst)=localtime((stat(&quot;file2&quot;))[9]);
printf(&quot;DATE=%04d%02d%02d\n&quot;,$yy+1900,$mm+1,$dd);
printf(&quot;TIME=%02d%02d%02d\n&quot;,$hh,$mn,$ss);'`

Hope This Help
PH.
 

FILE_CREATED_TIME=`ls -l $filename | awk ' { print $6 $7 $8 }'`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top