특정 확장명을 가진 파일을 삭제하기 위해 반복적으로 디렉터리를 반복하는 방법
원글링크
간단한 소스이니 여기에 첨부하고 별도의 설명은 없다 ▼
특정 파일을 삭제
recursiverm() {
for d in *; do
if [ -d "$d" ]; then
(cd -- "$d" && recursiverm)
fi
rm -f *.pdf
rm -f *.doc
done
}
(cd /tmp; recursiverm)
특정 단어가 포함된 라인을 삭제
recursivedeline() {
for d in *; do
if [ -d "$d" ]; then
(cd -- "$d" && recursivedeline);
fi;
for file in *; do
if [ -f "$file" ]; then
ex +g/lib2450//Uart\.h/d -cwq "$file"
fi
done;
done;
}
(cd /tmp; recursivedeline)
특정 단어를 치환
recursivereplace() {
for d in *; do
if [ -d "$d" ]; then
(cd -- "$d" && recursivereplace);
fi;
for file in *; do
if [ -f "$file" ]; then
ed -s "$file" <<< $',s/Windows(R)-compatible/POSIX-conform/g\nw'
fi
done;
done;
}
(cd /tmp; recursivereplace)