
bash find 명령을 사용하는 데 약간의 어려움이 있습니다.
문제는 *.appstrng가 포함된 *.app 파일에서 모든 레코드를 삭제하라는 요청이 늦어졌다는 것입니다."
다음은 레코드를 제거하려는 부정적인 시도 없이 완벽하게 실행되는 초기 조회 파이프라인입니다.
find . -type f -iname "*.app" -exec grep -we selected_apps -e app_name --color=auto --with-filename {} \; > LOG.txt
이제 LOG.txt를 생성하기 전에 .appstring 스트리핑을 추가하려는 몇 가지 시도가 있습니다.
1) grep -v를 사용하세요
find . -type f -iname "*.app" -exec grep -we selected_apps -e app_name -ev "*.appstring" --color=auto --with-filename {} \; > LOG.txt
2) awk를 사용하세요
find . -type f -iname "*.app" -exec grep -we selected_apps --color=auto --with-filename {} \; | awk '!/*.appstring/' > LOG.txt
find/grep 또는 find/awk가 이런 식으로 작동할지 잘 모르겠습니다... 모든 의견을 환영합니다! 감사해요! !
답변1
원래 명령을 사용하고 추가 명령을 사용하여 일부 결과를 제거할 수 있습니다.
cat LOG.txt | while read FILE; do
if ! grep -q "*.appstring" "$FILE"; then
echo $FILE >> LOG-filtered.txt
fi
done