STYLE: adjust ordering of 'find' command arguments

- use -name test before -type test to avoid calling stat(2) on every file.
- use -delete instead of -exec rm to avoid forking
This commit is contained in:
mark
2017-02-21 19:19:04 +01:00
parent a6d37e5728
commit 9e2e111518
17 changed files with 35 additions and 30 deletions

View File

@ -35,6 +35,7 @@ then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
exec 1>&2
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all core files"
exit 1
@ -45,8 +46,8 @@ for i
do
if [ -d "$i" ]
then
echo "removing all core files: $i"
find $i \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm 2>/dev/null
echo "removing all core files: $i" 1>&2
find $i \( -name core -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -type f -delete
else
echo "no directory: $i" 1>&2
fi