将历史记录时间戳替换为标准时间

#!/bin/sh
history_dir=/tmp/history/test/2012-11-20                #历史日志目录
for file_name in $history_dir/*
do
        while read file
        do
         time=`echo $file | grep "#"`                                                    
         if [ $? -eq 0 ]                                                                        
         then
                new_time=`echo $time | sed 's/#//g'`
                date_time=`echo $new_time | awk '{print strftime ("%F %T",$0)}'`
                sed -i "s/$time/$date_time/g" $file_name
         fi
        done<$file_name
done
替换前日志格式以下:
  #1353398866
  ls /root/
  #1353398881
  history -w
替换后日志格式以下:
  2012-11-20 16:07:46
  ls /root/
  2012-11-20 16:08:01
  history -w