From b612b6281a424556f6ed30d421214d0aa32ded55 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Thu, 12 Jan 2017 19:53:07 -0600 Subject: [PATCH] Use delete action for clean up *.pyc files Findutils added in release 4.2.3 a new --delete action for deleting matching files. This action performs better than -exec rm {} \; because it doesn't have to spawn an external process. This change uses a new action whenever is possible. Change-Id: Iff16a86b18e924cfe78ac7c6107910940ce51e03 --- clean.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clean.sh b/clean.sh index e369eda26c..90b21eb353 100755 --- a/clean.sh +++ b/clean.sh @@ -149,5 +149,10 @@ rm -rf ~/.config/openstack # Clean up all *.pyc files if [[ -n "$DEST" ]] && [[ -d "$DEST" ]]; then - sudo find $DEST -name "*.pyc" -print0 | xargs -0 rm + find_version=`find --version | awk '{ print $NF; exit}'` + if vercmp "$find_version" "<" "4.2.3" ; then + sudo find $DEST -name "*.pyc" -print0 | xargs -0 rm + else + sudo find $DEST -name "*.pyc" -delete + fi fi