$HOME/history 格式处理的shell脚本,感兴趣的朋友可以参考下。
复制代码代码如下:
#!/bin/bash
cat tomcat_history | while read line;do #每行读 zhifu_1=`echo ${line:0:1}` if [ $zhifu_1 = "#" ];then zhifu_2=`echo ${line:1}` date_1=`echo $zhifu_2 | awk '{print strftime("%Y-%m-%d %T",$1)}'` #时间格式 echo -n "$date_1" # 取消换行 else echo " $line" fi done |