-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.sh
More file actions
executable file
·31 lines (25 loc) · 722 Bytes
/
clean.sh
File metadata and controls
executable file
·31 lines (25 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Array of filenames or patterns to delete
files_to_delete=(
"*.d.ts"
"*.js"
)
# Directories to exclude
exclude_dirs=(
"./node_modules"
"./dist"
"./docs"
)
# Build the exclusion part of the find command
exclude_expr=""
for dir in "${exclude_dirs[@]}"; do
exclude_expr="$exclude_expr -path \"$dir\" -prune -o"
done
# Remove the trailing -o from the exclude_expr
exclude_expr="${exclude_expr%-o}"
# Loop through the array and delete matching files, excluding specified directories
for file in "${files_to_delete[@]}"; do
echo "Deleting files matching: $file (excluding ${exclude_dirs[*]})"
find . \( $exclude_expr \) -name "$file" -type f -print | xargs rm -f
done
echo "Deletion complete."