All pastes #937104 Raw Edit

toxickore

public shellscript v1 · immutable
·published 2008-03-10 21:12 UTC
rendered paste body
		#If there is more than 10 directories then delete the older ones        	if [ $TOTAL -gt 10 ]; then 	                #Number of iterations (directory deletions to do)			let ITER=$TOTAL-10                	while [[ $ITER -gt 0 ]] ; do                        	#Select the older element   	          	        ELEMENT=$(ls -lrt | awk '{print $9}' | head -2 | tail -1)        	                echo "Deleting $ELEMENT"  	                        #Delete the older element        	                #ls -lrt | awk '{print $9}' | head -2 | tail -1 | xargs rm -fr                	        let ITER=$ITER-1	                done        	else                	echo "Cannot delete more log files"                	exit 1		fi        fifi