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 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.
119file_count=${# files[@]}
1210
13- # Delete the files.
1411for file in " ${files[@]} " ; do
1512 rm " $file "
1613done
1714
18- # Print the number of files deleted.
1915echo " Deleted $file_count files."
You can’t perform that action at this time.
0 commit comments