只保留某个目录下最新的so文件[用于清除LCULIB目录下的老so文件]

#!/bin/sh
#
# remove old so-lib at make submit
#
# @auth [email protected]
#

#
# Usage:
#	keep_single_dir /ngboss/tuxapp/lculib /ngboss/tuxapp/lculib_old
#
keep_sosingle() {
	LCULIBDIR=$1
	LCULIBDIR_OLD=$2
	find $LCULIBDIR -type f -name "lib*" | awk -F\- '{print $1}' | sort | uniq |\
	while read prefix_so; do
		idx=1
		ls $prefix_so* | sort -r | \
		while read file; do
			if [ $idx -ne 1 ]; then
				echo "moving " $file " from " $LCULIBDIR " to " $LCULIBDIR_OLD
				mv $file $LCULIBDIR_OLD
			fi
			let idx=idx+1	
		done
	done
}

keep_sosingle $1 $2


你可能感兴趣的:(F#)