test

mail@pastecode.io avatar
unknown
batchfile
16 days ago
744 B
2
Indexable
Never
#!/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."
Leave a Comment