svn status --no-ignore | grep '^[I?]' | cut -c 9- | while IFS= read -r f; do rm -rf "$f"; done
Điều này có các tính năng sau:
- Cả hai tập tin bị bỏ qua và không bị theo dõi đều bị xóa
- Nó hoạt động ngay cả khi tên tệp chứa khoảng trắng (ngoại trừ dòng mới, nhưng không có nhiều thứ có thể được thực hiện ngoài việc sử dụng
--xmltùy chọn và phân tích kết quả xml kết quả)
- Nó hoạt động ngay cả khi
svn statusin các ký tự trạng thái khác trước tên tệp (không nên vì các tệp không được theo dõi, nhưng chỉ trong trường hợp ...)
- Nó nên hoạt động trên mọi hệ thống tuân thủ POSIX
Tôi sử dụng một tập lệnh shell có tên svncleannhư sau:
#!/bin/sh
# make sure this script exits with a non-zero return value if the
# current directory is not in a svn working directory
svn info >/dev/null || exit 1
svn status --no-ignore | grep '^[I?]' | cut -c 9- |
# setting IFS to the empty string ensures that any leading or
# trailing whitespace is not trimmed from the filename
while IFS= read -r f; do
# tell the user which file is being deleted. use printf
# instead of echo because different implementations of echo do
# different things if the arguments begin with hyphens or
# contain backslashes; the behavior of printf is consistent
printf '%s\n' "Deleting ${f}..."
# if rm -rf can't delete the file, something is wrong so bail
rm -rf "${f}" || exit 1
done