pdf How to archive the most recent directories
Par keyphrene, Thursday 10 June 2010 à 11:47 :: Org.keyphrene - 4Py :: #29 :: rss
How to archive the most recent directories. (Tutorial Shell Unix)
archive_directory() { local n=0 local arch=5 local arch_path="" if [ -d "$1" ]; then arch_path=$1 else echo archive_directory: $1 not found return fi if [ -n "$2" ]; then arch=$2 fi echo $arch_path $arch d=ARCH_`date +%Y%m%d` mkdir -p $d find $arch_path -type f -mindepth 1 -maxdepth 1 | while read i do mv "$i" "$arch_path/$d/" done # Remove ARCH_ find $arch_path -type d -mindepth 1 -maxdepth 1 | sort -r | while read i do n=$(($n+1)) if [ $n -le $arch ]; then echo "Keep $i" continue fi echo "Delete $i" rm -fr "$i" done } # Archiving the five last directories archive_directory D:/temp/tmp
TAGS : Tutorial Shell Unix archive recent directory forlder Script DOS

Comments
No comment for this moment.
Add a comment