Created
July 18, 2023 17:05
-
-
Save SOSANA/251b54396bceb24d21e7f916a00104a2 to your computer and use it in GitHub Desktop.
a bash script to remove all files named "file-type" in the root directory and subfolders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# remove all files named "file-type" in the root directory and subfolders | |
# bash remove_files.sh | |
# Get the current directory | |
current_dir=$(pwd) | |
# Initialize counter for file-type files | |
file_type_count=0 | |
# Find and delete files named "file-type" | |
while IFS= read -r -d '' file; do | |
rm -f "$file" | |
echo "Deleted: $file" | |
((file_type_count++)) | |
done < <(find "$current_dir" -type f -name "file-type" -print0) | |
# Log the completion message with the count | |
echo "Deletion process completed." | |
echo "\"file-type\" files deleted: $file_type_count" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment