`

获取文件时间

 
阅读更多

文件脚本

#!/bin/bash
file_path=$1
modify_time=`stat -c %x $file_path`
echo $modify_time
format_time=`date --date="$modify_time" "+%F %T"`
echo $format_time

 判断给定路径文件是否存在

#!/bin/bash
file_path=$1
modify_time=`stat -c %x $file_path`
echo $modify_time
format_time=`date --date="$modify_time" "+%F %T"`
echo $format_time
if [ -f "$file_path" ]; then
echo "exist"
else
echo "empty"
fi

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics