Operating System - HP-UX
1753936 Members
9518 Online
108811 Solutions
New Discussion юеВ

i want to print one log file with time and date

 
rajesh73
Super Advisor

i want to print one log file with time and date

i want to print one log file with time and date vmstat > /home/raj/ file name with time and date .txt
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: i want to print one log file with time and date

Is there anything wrong with the simple method of

 

date > /home/raj/ file

vmstat >> /home/raj/ file


Pete
Pete Randall
Outstanding Contributor

Re: i want to print one log file with time and date

Or do you want the date stamp in the name of the file?

 

vmstat > /home/raj/file`date`


Pete
Dennis Handly
Acclaimed Contributor

Re: I want to print one log file with time and date

>Is there anything wrong with the simple method of

 

Or even: { date; vmstat; } > /home/raj/ file

 

>Or do you want the date stamp in the name of the file?

 

And: vmstat > /home/raj/file$(date)

James R. Ferguson
Acclaimed Contributor

Re: I want to print one log file with time and date

Hi:

 

And if you want to tag every line with a date stamp, you could do:

 

vmstat | while read LINE
do
    echo "$(date '+%m/%d/%Y') ${LINE}"
done 

 ...which written on a command line is:

 

vmstat|while read LINE; do echo "$(date '+%m/%d/%Y') ${LINE}"; done 

Regards!

 

...JRF...