mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
if [ "$#" -gt 0 ]
|
if [ "$#" -gt 0 ]
|
||||||
then
|
then
|
||||||
find . -name "*.[CHL]" -exec $1 {} \; -print
|
find . -name "*.[CHL]" -type f -exec $1 {} \; -print
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -119,7 +119,7 @@ else
|
|||||||
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar &&
|
( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar &&
|
||||||
|
|
||||||
echo "add in time-stamp and lnInclude directories" 1>&2 &&
|
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 &&
|
tar Af $packBase.tar $packBase.tar2 &&
|
||||||
|
|
||||||
echo "gzip tar file" 1>&2 &&
|
echo "gzip tar file" 1>&2 &&
|
||||||
|
|||||||
@ -93,7 +93,7 @@ if [ ! -d $DIR ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
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)
|
NAMES=$(for f in $FILES; do basename $f .vtk; done | sort -u)
|
||||||
|
|
||||||
if [ -d $OUT ]; then
|
if [ -d $OUT ]; then
|
||||||
|
|||||||
@ -35,6 +35,7 @@ then
|
|||||||
set -- .
|
set -- .
|
||||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||||
then
|
then
|
||||||
|
exec 1>&2
|
||||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
||||||
echo " remove all core files"
|
echo " remove all core files"
|
||||||
exit 1
|
exit 1
|
||||||
@ -45,8 +46,8 @@ for i
|
|||||||
do
|
do
|
||||||
if [ -d "$i" ]
|
if [ -d "$i" ]
|
||||||
then
|
then
|
||||||
echo "removing all core files: $i"
|
echo "removing all core files: $i" 1>&2
|
||||||
find $i \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm 2>/dev/null
|
find $i \( -name core -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -type f -delete
|
||||||
else
|
else
|
||||||
echo "no directory: $i" 1>&2
|
echo "no directory: $i" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -35,6 +35,7 @@ then
|
|||||||
set -- .
|
set -- .
|
||||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||||
then
|
then
|
||||||
|
exec 1>&2
|
||||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
||||||
echo " remove all *~ files"
|
echo " remove all *~ files"
|
||||||
exit 1
|
exit 1
|
||||||
@ -45,8 +46,8 @@ for i
|
|||||||
do
|
do
|
||||||
if [ -d "$i" ]
|
if [ -d "$i" ]
|
||||||
then
|
then
|
||||||
echo "removing all *~ files: $i"
|
echo "removing all *~ files: $i" 1>&2
|
||||||
find $i \( -name '*~' -o -name '.*~' \) -print | xargs -t rm 2>/dev/null
|
find $i \( -name '*~' -o -name '.*~' \) -type f -delete -print
|
||||||
else
|
else
|
||||||
echo "no directory: $i" 1>&2
|
echo "no directory: $i" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -4,10 +4,14 @@ cd ${0%/*} || exit 1 # Run from this directory
|
|||||||
echo "--------"
|
echo "--------"
|
||||||
echo "Cleaning tutorials ..."
|
echo "Cleaning tutorials ..."
|
||||||
echo "Removing backup files"
|
echo "Removing backup files"
|
||||||
find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \;
|
|
||||||
find . \( -name core -o -name 'core.[1-9]*' \) -exec rm {} \;
|
find . \( \
|
||||||
find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \;
|
-name '*~' -o -name '*.bak' \
|
||||||
rm logs testLoopReport > /dev/null 2>&1
|
-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
|
foamCleanTutorials cases
|
||||||
|
|
||||||
|
|||||||
@ -138,7 +138,7 @@ do
|
|||||||
[ -d $appDir ] || continue
|
[ -d $appDir ] || continue
|
||||||
echo -n " $appDir..." 1>&2
|
echo -n " $appDir..." 1>&2
|
||||||
|
|
||||||
logs=$(find -L $appDir -type f -name 'log.*')
|
logs=$(find -L $appDir -name 'log.*' -type f)
|
||||||
if [ -n "$logs" ]
|
if [ -n "$logs" ]
|
||||||
then
|
then
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
|
|||||||
@ -211,7 +211,7 @@ fi
|
|||||||
echo "Modifying the controlDicts to run only one time step" 1>&2
|
echo "Modifying the controlDicts to run only one time step" 1>&2
|
||||||
cd ${TEST_RUN_DIR} || exit 1
|
cd ${TEST_RUN_DIR} || exit 1
|
||||||
|
|
||||||
for CD in $(find . -type f -name "controlDict*")
|
for CD in $(find . -name "controlDict*" -type f)
|
||||||
do
|
do
|
||||||
mv ${CD} ${CD}.orig
|
mv ${CD} ${CD}.orig
|
||||||
sed \
|
sed \
|
||||||
@ -225,7 +225,7 @@ done
|
|||||||
if [ "$DEFAULT_SCHEMES" = true ]
|
if [ "$DEFAULT_SCHEMES" = true ]
|
||||||
then
|
then
|
||||||
echo "Modifying the fvSchemes to contain only default schemes" 1>&2
|
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
|
do
|
||||||
for S in $FV_SCHEMES
|
for S in $FV_SCHEMES
|
||||||
do
|
do
|
||||||
@ -253,7 +253,7 @@ do
|
|||||||
do
|
do
|
||||||
rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1
|
rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1
|
||||||
echo " ${ST}" >> $SCHEMES_FILE
|
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
|
do
|
||||||
for S in $(grep ${ST} ${LOG} | cut -d" " -f4)
|
for S in $(grep ${ST} ${LOG} | cut -d" " -f4)
|
||||||
do
|
do
|
||||||
|
|||||||
@ -17,7 +17,7 @@ runApplication decomposePar -decomposeParDict system/decomposeParDict.hierarchic
|
|||||||
# \cp system/decomposeParDict.ptscotch system/decomposeParDict
|
# \cp system/decomposeParDict.ptscotch system/decomposeParDict
|
||||||
runParallel snappyHexMesh -decomposeParDict system/decomposeParDict.ptscotch -profiling -overwrite
|
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
|
#- Set the initial fields
|
||||||
restore0Dir -processor
|
restore0Dir -processor
|
||||||
|
|||||||
@ -14,7 +14,7 @@ runApplication decomposePar
|
|||||||
\cp system/decomposeParDict.ptscotch system/decomposeParDict
|
\cp system/decomposeParDict.ptscotch system/decomposeParDict
|
||||||
runParallel snappyHexMesh -overwrite
|
runParallel snappyHexMesh -overwrite
|
||||||
|
|
||||||
find . -type f -iname "*level*" -exec rm {} \;
|
find . -iname '*level*' -type f -delete
|
||||||
|
|
||||||
# - Set the initial fields
|
# - Set the initial fields
|
||||||
restore0Dir -processor
|
restore0Dir -processor
|
||||||
|
|||||||
@ -56,7 +56,7 @@ do
|
|||||||
done >> Make/files
|
done >> Make/files
|
||||||
[ -s Make/files ] && echo >> 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
|
do
|
||||||
pathName=$(echo ${file%/*} | $dirToString -strip)
|
pathName=$(echo ${file%/*} | $dirToString -strip)
|
||||||
|
|
||||||
|
|||||||
@ -153,10 +153,10 @@ then
|
|||||||
|
|
||||||
# Get sub-directories avoiding particular directories
|
# Get sub-directories avoiding particular directories
|
||||||
for dir in $(find . -mindepth 1 -maxdepth 1 \
|
for dir in $(find . -mindepth 1 -maxdepth 1 \
|
||||||
-type d \( -name .git -prune -o -print \) )
|
-name .git -prune -o -type d -print)
|
||||||
do
|
do
|
||||||
echo " searching: $dir"
|
echo " searching: $dir"
|
||||||
find $dir -depth -type d -empty -exec rmdir {} \; -print
|
find $dir -depth -empty -type d -delete -print
|
||||||
done
|
done
|
||||||
|
|
||||||
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
|
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
|
||||||
|
|||||||
@ -58,7 +58,7 @@ do
|
|||||||
if [ -d "$dir" ]
|
if [ -d "$dir" ]
|
||||||
then
|
then
|
||||||
echo "removing lnInclude directories: $dir"
|
echo "removing lnInclude directories: $dir"
|
||||||
find $dir -depth -type d -name lnInclude -exec rm -rf {} \;
|
find $dir -depth -name lnInclude -type d -delete
|
||||||
else
|
else
|
||||||
echo "no directory: $dir" 1>&2
|
echo "no directory: $dir" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -89,7 +89,7 @@ then
|
|||||||
rm -rf platforms/*
|
rm -rf platforms/*
|
||||||
|
|
||||||
echo "Removing lnInclude directories"
|
echo "Removing lnInclude directories"
|
||||||
find . -depth -type d \( -name lnInclude \) | xargs rm -rf
|
find . -depth -name lnInclude -type d -delete
|
||||||
|
|
||||||
tutorials/Allclean
|
tutorials/Allclean
|
||||||
else
|
else
|
||||||
|
|||||||
@ -149,7 +149,7 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Remove any broken links first (this helps when file locations have moved)
|
# Remove any broken links first (this helps when file locations have moved)
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
find -L . -type l | xargs rm -f
|
find -L . -type l -delete
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
11
wmake/wrmdep
11
wmake/wrmdep
@ -152,15 +152,14 @@ files)
|
|||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "removing all .dep files ..."
|
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
|
else
|
||||||
echo "removing .o files corresponding to"
|
echo "removing .o files corresponding to"
|
||||||
echo " $@ ..."
|
echo " $@ ..."
|
||||||
for file
|
for file
|
||||||
do
|
do
|
||||||
find $objectsDir -type f -name '*.dep' \
|
find $objectsDir -name '*.dep' -type f \
|
||||||
-exec grep -q "$file" '{}' \; \
|
-exec grep -q "$file" {} \; -delete -print
|
||||||
-exec rm '{}' \; -print
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -183,7 +182,7 @@ oldFolders)
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $objectsDir -type f -name '*.dep' -print | while read depFile
|
find $objectsDir -name '*.dep' -type f -print | while read depFile
|
||||||
do
|
do
|
||||||
sourceFile=$(depToSource $depFile)
|
sourceFile=$(depToSource $depFile)
|
||||||
|
|
||||||
@ -205,7 +204,7 @@ updateMode)
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Removing dep files corresponding to source files that no longer exist..."
|
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
|
for filePathAndName in $fileNameList
|
||||||
do
|
do
|
||||||
|
|||||||
@ -103,7 +103,7 @@ fi
|
|||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "removing all .o files ..."
|
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
|
else
|
||||||
echo "removing .o files corresponding to"
|
echo "removing .o files corresponding to"
|
||||||
echo " $@ ..."
|
echo " $@ ..."
|
||||||
|
|||||||
Reference in New Issue
Block a user