# Temporary file to hold all tracked and untracked files not ignored by .gitignore TEMP_FILE_LIST=$(mktemp) # Get all files tracked by git git ls-files > "$TEMP_FILE_LIST" # Add all untracked files not ignored by .gitignore to the list git ls-files --others --exclude-standard >> "$TEMP_FILE_LIST" # Find files larger than 100MB echo "Checking for files larger than 10MB that are not ignored by .gitignore…" while IFS= read -r file; do # Skip if file does not exist (e.g., was deleted) if [[ ! -e "$file" ]]; then continue fi # Get file size in bytes using the correct option for Linux file_size=$(stat --format=%s "$file") # If file size is greater or equal to 100MB (100*1024*1024 bytes) if [[ "$file_size" -ge $((10*1024*1024)) ]]; then echo "$file is $(($file_size / 1024 / 1024))MB" fi done < "$TEMP_FILE_LIST" # Cleanup rm "$TEMP_FILE_LIST"