Skip to content

Instantly share code, notes, and snippets.

@sandacn
Created June 30, 2019 02:54
Show Gist options
  • Save sandacn/448ace4923264110d69a056ea41aa422 to your computer and use it in GitHub Desktop.
Save sandacn/448ace4923264110d69a056ea41aa422 to your computer and use it in GitHub Desktop.
修改文件的最后修改时间
#!/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