pathScripts/gitscan

24 lines
668 B
Text
Raw Normal View History

#!/bin/bash
2024-08-03 09:22:15 +02:00
output_file="./repos.txt"
2024-08-03 09:22:15 +02:00
# Clear the existing file or create it if it doesn't exist
> "$output_file"
2024-08-03 09:22:15 +02:00
# Find all .git directories in the current folder and subfolders,
# excluding hidden directories and suppressing permission denied errors
find . -type d -name ".git" -not -path "*/.*/*" 2>/dev/null | while read -r gitdir; do
# Get the parent directory of the .git folder
repo_path=$(dirname "$gitdir")
echo "$repo_path" >> "$output_file"
done
echo "Git repositories have been written to $output_file"
# Remove duplicate entries
sort -u "$output_file" -o "$output_file"
echo "Duplicate entries removed. Final list:"
cat "$output_file"