File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
# 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.
4
3
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 )
9
8
10
- # Count the number of files found.
11
9
file_count=${# files[@]}
12
10
13
- # Delete the files.
14
11
for file in " ${files[@]} " ; do
15
12
rm " $file "
16
13
done
17
14
18
- # Print the number of files deleted.
19
15
echo " Deleted $file_count files."
You can’t perform that action at this time.
0 commit comments