Skip to content

Commit 469f41e

Browse files
committed
remove_bad_files script does not rely on mapfile
#build
1 parent 68e029c commit 469f41e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
#!/bin/bash
22
# This script finds and deletes all files with the extension ".bad.*" in the current directory and its subdirectories.
3-
# It is useful for cleaning up unwanted or temporary files generated during testing or development.
43

5-
# Use the find command to locate all files with the ".bad.*" extension and store them in an array.
6-
# The -name option specifies the pattern to match.
7-
# The -type f option ensures that only files are matched.
8-
mapfile -t files < <(find . -name "*.bad.*" -type f)
4+
files=()
5+
while IFS= read -r -d $'\0' file; do
6+
files+=("$file")
7+
done < <(find . -name "*.bad.*" -type f -print0)
98

10-
# Count the number of files found.
119
file_count=${#files[@]}
1210

13-
# Delete the files.
1411
for file in "${files[@]}"; do
1512
rm "$file"
1613
done
1714

18-
# Print the number of files deleted.
1915
echo "Deleted $file_count files."

0 commit comments

Comments
 (0)