上次需要的功能~csdn上求教才解決的~嘿嘿~
代码
#!/bin/sh
voicedir="/var/www/html/"
datestr=`date -d "yesterday" +%Y%m%d`
if [ ! -d "$voicedir$datestr" ]; then
mkdir "$voicedir$datestr"
fi
ls -l $voicedir --time-style '+%Y%m%d' | grep "^-" | awk '$6~/'$datestr'/{print $NF}' | xargs -i mv $voicedir{} $voicedir$datestr/
voicedir="/var/www/html/"
datestr=`date -d "yesterday" +%Y%m%d`
if [ ! -d "$voicedir$datestr" ]; then
mkdir "$voicedir$datestr"
fi
ls -l $voicedir --time-style '+%Y%m%d' | grep "^-" | awk '$6~/'$datestr'/{print $NF}' | xargs -i mv $voicedir{} $voicedir$datestr/
到要移動的目錄下執行
ls -l --time-style '+%Y%m%d' | awk '$1~/^-/{system("test ! -d "$6" && mkdir "$6";mv "$NF" "$6)}'