I want to ignore all hidden files, but especially .git and .svn ones when searching (and later replacing) files, not I have found that the most basic way to exclude such hidden files described in many online tutorials doesn't work here.
find . -not -name ".*"
will also print hidden files.
The script I'm trying to write is
replace() {
if [ -n "$3" ]; then expr="-name "$3""; fi
find . -type f ( $expr -not -name ".*" ) -exec echo sed -i 's/$1/$2/g' {} ;
unset expr
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…