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

@ -4,10 +4,14 @@ cd ${0%/*} || exit 1 # Run from this directory
echo "--------"
echo "Cleaning tutorials ..."
echo "Removing backup files"
find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \;
find . \( -name core -o -name 'core.[1-9]*' \) -exec rm {} \;
find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \;
rm logs testLoopReport > /dev/null 2>&1
find . \( \
-name '*~' -o -name '*.bak' \
-name core -o -name 'core.[1-9]*' \
-name '*.pvs' -o -name '*.OpenFOAM' \
\) -type f -delete
rm -f logs testLoopReport > /dev/null 2>&1
foamCleanTutorials cases

View File

@ -138,7 +138,7 @@ do
[ -d $appDir ] || continue
echo -n " $appDir..." 1>&2
logs=$(find -L $appDir -type f -name 'log.*')
logs=$(find -L $appDir -name 'log.*' -type f)
if [ -n "$logs" ]
then
echo 1>&2

View File

@ -211,7 +211,7 @@ fi
echo "Modifying the controlDicts to run only one time step" 1>&2
cd ${TEST_RUN_DIR} || exit 1
for CD in $(find . -type f -name "controlDict*")
for CD in $(find . -name "controlDict*" -type f)
do
mv ${CD} ${CD}.orig
sed \
@ -225,7 +225,7 @@ done
if [ "$DEFAULT_SCHEMES" = true ]
then
echo "Modifying the fvSchemes to contain only default schemes" 1>&2
for FV_SC in $(find . -type f -name fvSchemes)
for FV_SC in $(find . -name fvSchemes -type f)
do
for S in $FV_SCHEMES
do
@ -253,7 +253,7 @@ do
do
rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1
echo " ${ST}" >> $SCHEMES_FILE
for LOG in $(find ${APP} -type f -name "log.${APP}")
for LOG in $(find ${APP} -name "log.${APP}" -type f)
do
for S in $(grep ${ST} ${LOG} | cut -d" " -f4)
do

View File

@ -17,7 +17,7 @@ runApplication decomposePar -decomposeParDict system/decomposeParDict.hierarchic
# \cp system/decomposeParDict.ptscotch system/decomposeParDict
runParallel snappyHexMesh -decomposeParDict system/decomposeParDict.ptscotch -profiling -overwrite
find . -type f -iname "*level*" -exec rm {} \;
find . -iname '*level*' -type f -delete
#- Set the initial fields
restore0Dir -processor

View File

@ -14,7 +14,7 @@ runApplication decomposePar
\cp system/decomposeParDict.ptscotch system/decomposeParDict
runParallel snappyHexMesh -overwrite
find . -type f -iname "*level*" -exec rm {} \;
find . -iname '*level*' -type f -delete
# - Set the initial fields
restore0Dir -processor