大部分 linux 系统并不存在创建时间。随机时间可以这么写:day_of_month=(0 31 28 31 30 31 30 31 31 30 31 30 31) for file in $(ls *.log); do year=$(( 1901 + $RANDOM % 120 )) month=$((RANDOM % 12 + 1)) day=$((RANDOM % ${day_of_month[$month]} + 1)) month=0$month day=0$day date=$year${month:(-2):2}${day:(-2):2} touch $file -d $date echo "Rand date for $file: $date" done按文件名改时间可以这么写:for file in $(ls *.log); do touch $file -d ${file%%.log} echo "Touched $file: ${file%%.log}" done
大部分 linux 系统并不存在创建时间。
随机时间可以这么写:
按文件名改时间可以这么写: