I'm able to convert the first field from epoch time format to "normal date" format and also separate the field with comma with awk command (directly from the rrdtool fetch command) :
Code:
/usr/bin/rrdtool fetch rrdfiles.rrd AVERAGE -r 3600 -e "Mar 20 2014" -s e-14d | cut -f1-2 -d":" |\
sed 's/://g' | sed '/-nan/d' | awk '{print strftime("%c",$1)","($2)","($3)}'
Code:
Thu 20 Mar 2014 01:00:00 PM WIT,2.0629986254e+06,7.4634784967e+05
Thu 20 Mar 2014 01:30:00 PM WIT,2.0198121616e+06,6.8658888903e+05
Thu 20 Mar 2014 02:00:00 PM WIT,1.8787141122e+06,6.7482866452e+05
Thu 20 Mar 2014 02:30:00 PM WIT,1.7586118678e+06,6.7867977653e+05
Thu 20 Mar 2014 03:00:00 PM WIT,1.8222762151e+06,7.1301678859e+05
What I want to achieve is how to format the second and third field to decimal format with awk printf command :
Code:
printf "%12.2f\n"
The final output should be :
Code:
Thu 20 Mar 2014 01:00:00 PM WIT,2062998.6254,746347.8497
Thu 20 Mar 2014 01:30:00 PM WIT,2019812.1616,686588.8890
Thu 20 Mar 2014 02:00:00 PM WIT,1878714.1122,674828.6645
Thu 20 Mar 2014 02:30:00 PM WIT,1758611.8678,678679.7765
Thu 20 Mar 2014 03:00:00 PM WIT,1822276.2151,713016.7886
How to combine print strftime and printf command in one line ? . Sorry I have try several combination but not work.
Or maybe there are other solution.
Here is the code I'm using
{
printf("%11d %4.2f\% %4.2f\%\n", $1,$2,$3);
}
I want the output to look something like
1235415234 12.24% 52.46%
Instead it looks something like
319203842 42.27\%4.2f\%
How do I just print a "%" without awk or printf thinking I'm trying to do... (1 Reply)
Hi Everyone
i have a perl file below, one of the line is convert the pcho time to human readable format.
$value=`awk 'BEGIN{print strftime("%c",1273236600)}' | tr -d '\n'`;
if image, if i have lots of pcho time value in a file, if i use this awk, strftime, then tr -d to remove the \n,... (2 Replies)
hallow all i need your advice about this script
i have script like this:
INDEX=/zpool1/NFS/INDEX/${1}
SCRIPT=/zpool1/NFS/script/${1}
LIST=SAMPLE
cd ${SCRIPT}
for i in `cat ${LIST}`
do
GETDATE=`echo ${i}|awk '{print substr($1,9,8)}'`
/usr/xpg4/bin/awk -F ":" '{close(f);f=$4}{print >>... (4 Replies)
hi all i need to add the prinf statement in awk command for the converted comma separated output....
below is my code :
Code Credits :RudiC
awk -F, 'NF==2 {next}
{ITM=$1
AMT=$2+0
CNT=$3+0
TOTA+=$2
... (4 Replies)