Created
June 30, 2019 02:54
-
-
Save sandacn/448ace4923264110d69a056ea41aa422 to your computer and use it in GitHub Desktop.
修改文件的最后修改时间
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=$1 | |
if [ ! -d $dir ]; | |
then | |
echo "$dir does not exist" | |
exit 1 | |
fi | |
cd $dir | |
mtime="" | |
ls . | while read f | |
do | |
echo $f | |
eval $(stat -s "$f") | |
if [ -z "$mtime" ]; | |
then | |
mtime=$st_mtime | |
else | |
mtime=$(($mtime + 60)) | |
fi | |
echo $mtime | |
echo "gdate -d @$mtime '+%Y%m%d%H%M%S'" | |
fmdate=`gdate -d @$mtime +%Y%m%d%H%M%S` | |
echo $fmdate | |
fmtime=`awk 'BEGIN{printf("%0.2f", ('$fmdate'/100))}' ` | |
echo $fmtime | |
if [ -f "$f" ]; | |
then | |
echo "touch -t $fmtime $f" | |
touch -t $fmtime "$f" | |
else | |
echo "$f maybe broken" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment