
의 내용은 다음과 같습니다..gitignore
cron.yaml
build
target
webview
*.pyc
*.sublime-workspace
.idea
*.rej
.coverage
app/tools/temp_*.py
app/tools/*/temp_*.py
현재 다음 스크립트로 로컬 폴더의 파일을 반복하고 있습니다.
find . -type f | grep -v -E "(.idea|.git)" | while read file
do
# Do something with $file
done
이 $file
변수가 .gitignore
. 이러한 파일 패턴을 이해할 수 있는 기존 유틸리티나 bash 내장이 있습니까?
답변1
일부 패턴을 "정규화"하기 위해 프로세스 대체와 함께 의 일명 ( ) 옵션을 grep
사용할 -f
수 있습니다 . --file
예를 들어:
find . -type f | grep -Ev '(\.idea|\.git)' |
grep -v -f <(sed 's/\([.|]\)/\\\1/g; s/\?/./g ; s/\*/.*/g' .gitignore) |
while IFS= read -r file ; do
# Do something with "$file"
done