test
unknown
batchfile
a year ago
744 B
9
Indexable
#!/bin/bash
# Directory to check for duplicates
TARGET_DIR="/usr/lib/node_modules/root"
# Change to the target directory
cd "$TARGET_DIR" || { echo "Directory not found: $TARGET_DIR"; exit 1; }
# Use a temporary array to track seen files
declare -A seen_files
# Loop through files in the target directory
for file in *; do
# Check if it's a file
if [[ -f "$file" ]]; then
# If the file has not been seen before, add it to the seen_files array
if [[ -z ${seen_files["$file"]} ]]; then
seen_files["$file"]=1
else
# If the file is a duplicate, delete it
echo "Removing duplicate file: $file"
rm "$file"
fi
fi
done
echo "Duplicate removal completed."
Editor is loading...
Leave a Comment