mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
foamSearch: make it work within a read-only directory
Patch contributed by Bruno Santos: https://bugs.openfoam.org/view.php?id=2928
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -48,6 +48,7 @@ Searches the <directory> for files named <filename> and extracts entries with
|
|||||||
Examples:
|
Examples:
|
||||||
* Default ddtSchemes entries in the fvSchemes files in all tutorials:
|
* Default ddtSchemes entries in the fvSchemes files in all tutorials:
|
||||||
foamSearch $FOAM_TUTORIALS fvSchemes ddtSchemes.default
|
foamSearch $FOAM_TUTORIALS fvSchemes ddtSchemes.default
|
||||||
|
|
||||||
* Relaxations factors for U in fvSolutions files in all tutorials:
|
* Relaxations factors for U in fvSolutions files in all tutorials:
|
||||||
foamSearch -c $FOAM_TUTORIALS fvSolution relaxationFactors.equations.U
|
foamSearch -c $FOAM_TUTORIALS fvSolution relaxationFactors.equations.U
|
||||||
USAGE
|
USAGE
|
||||||
@ -75,19 +76,14 @@ esac
|
|||||||
[ "$#" -eq 3 ] || error "Wrong number of arguments: expected 3, found $#"
|
[ "$#" -eq 3 ] || error "Wrong number of arguments: expected 3, found $#"
|
||||||
[ -d "$1" ] || error "$1 is not a directory"
|
[ -d "$1" ] || error "$1 is not a directory"
|
||||||
|
|
||||||
tmp=$(mktemp tmp.XXXXXX)
|
|
||||||
files=$(find "$1" -name "$2")
|
files=$(find "$1" -name "$2")
|
||||||
[ -n "$files" ] || error "No file $2 found in $1"
|
[ -n "$files" ] || error "No file $2 found in $1"
|
||||||
|
|
||||||
for f in $files
|
for f in $files
|
||||||
do
|
do
|
||||||
foamDictionary -entry "$3" "$f" 2>/dev/null >> "$tmp"
|
foamDictionary -entry "$3" "$f" 2>/dev/null
|
||||||
done
|
done | \
|
||||||
|
sort | uniq $count | sed '/^[\t 1-9]*$/d' || \
|
||||||
[ -s "$tmp" ] && \
|
|
||||||
sort "$tmp" | uniq $count | sed '/^[\t 1-9]*$/d' || \
|
|
||||||
echo "No keyword $3 found in $2 files"
|
echo "No keyword $3 found in $2 files"
|
||||||
|
|
||||||
rm "$tmp" 2>/dev/null
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user