Commit 63bb0f78 authored by mark's avatar mark
Browse files

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
parent 6c89986e
......@@ -32,7 +32,7 @@
if [ "$#" -gt 0 ]
then
find . -name "*.[CHL]" -exec $1 {} \; -print
find . -name "*.[CHL]" -type f -exec $1 {} \; -print
fi
#------------------------------------------------------------------------------
......@@ -119,7 +119,7 @@ else
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar &&
echo "add in time-stamp and lnInclude directories" 1>&2 &&
tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build $(find -H $packDir -type d -name lnInclude) &&
tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build $(find -H $packDir -name lnInclude -type d) &&
tar Af $packBase.tar $packBase.tar2 &&
echo "gzip tar file" 1>&2 &&
......
......@@ -93,7 +93,7 @@ if [ ! -d $DIR ]; then
exit 0
fi
FILES=$(find $DIR -type f -name *vtk)
FILES=$(find $DIR -name '*.vtk' -type f)
NAMES=$(for f in $FILES; do basename $f .vtk; done | sort -u)
if [ -d $OUT ]; then
......
......@@ -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
......
......@@ -35,6 +35,7 @@ then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
exec 1>&2
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all *~ files"
exit 1
......@@ -45,8 +46,8 @@ for i
do
if [ -d "$i" ]
then
echo "removing all *~ files: $i"
find $i \( -name '*~' -o -name '.*~' \) -print | xargs -t rm 2>/dev/null
echo "removing all *~ files: $i" 1>&2
find $i \( -name '*~' -o -name '.*~' \) -type f -delete -print
else
echo "no directory: $i" 1>&2
fi
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -56,7 +56,7 @@ do
done >> Make/files
[ -s Make/files ] && echo >> Make/files
for file in $(find . -type f -name "*.[cCylLfF]" -print)
for file in $(find . -name "*.[cCylLfF]" -type f -print)
do
pathName=$(echo ${file%/*} | $dirToString -strip)
......
......@@ -153,10 +153,10 @@ then
# Get sub-directories avoiding particular directories
for dir in $(find . -mindepth 1 -maxdepth 1 \
-type d \( -name .git -prune -o -print \) )
-name .git -prune -o -type d -print)
do
echo " searching: $dir"
find $dir -depth -type d -empty -exec rmdir {} \; -print
find $dir -depth -empty -type d -delete -print
done
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
......
......@@ -58,7 +58,7 @@ do
if [ -d "$dir" ]
then
echo "removing lnInclude directories: $dir"
find $dir -depth -type d -name lnInclude -exec rm -rf {} \;
find $dir -depth -name lnInclude -type d -delete
else
echo "no directory: $dir" 1>&2
fi
......
......@@ -89,7 +89,7 @@ then
rm -rf platforms/*
echo "Removing lnInclude directories"
find . -depth -type d \( -name lnInclude \) | xargs rm -rf
find . -depth -name lnInclude -type d -delete
tutorials/Allclean
else
......
......@@ -149,7 +149,7 @@ fi
#------------------------------------------------------------------------------
# Remove any broken links first (this helps when file locations have moved)
#------------------------------------------------------------------------------
find -L . -type l | xargs rm -f
find -L . -type l -delete
#------------------------------------------------------------------------------
......
......@@ -152,15 +152,14 @@ files)
if [ "$#" -eq 0 ]
then
echo "removing all .dep files ..."
find $objectsDir -type f -name '*.dep' -print | xargs -t rm 2>/dev/null
find $objectsDir -name '*.dep' -type f -delete -print
else
echo "removing .o files corresponding to"
echo " $@ ..."
for file
do
find $objectsDir -type f -name '*.dep' \
-exec grep -q "$file" '{}' \; \
-exec rm '{}' \; -print
find $objectsDir -name '*.dep' -type f \
-exec grep -q "$file" {} \; -delete -print
done
fi
;;
......@@ -183,7 +182,7 @@ oldFolders)
continue
fi
find $objectsDir -type f -name '*.dep' -print | while read depFile
find $objectsDir -name '*.dep' -type f -print | while read depFile
do
sourceFile=$(depToSource $depFile)
......@@ -205,7 +204,7 @@ updateMode)
fi
echo "Removing dep files corresponding to source files that no longer exist..."
fileNameList=$(find -L src applications -type l -name '*.[CHL]')
fileNameList=$(find -L src applications -name '*.[CHL]' -type l)
for filePathAndName in $fileNameList
do
......
......@@ -103,7 +103,7 @@ fi
if [ "$#" -eq 0 ]
then
echo "removing all .o files ..."
find $objectsDir -type f -name '*.o' -print | xargs -t rm 2>/dev/null
find $objectsDir -name '*.o' -type f -delete
else
echo "removing .o files corresponding to"
echo " $@ ..."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment