Skip to content

Instantly share code, notes, and snippets.

@PetarKirov
Created April 10, 2022 13:17
Show Gist options
  • Save PetarKirov/0c4ea2808dcda152345d24405e708345 to your computer and use it in GitHub Desktop.
Save PetarKirov/0c4ea2808dcda152345d24405e708345 to your computer and use it in GitHub Desktop.
Parsing git remote project names and paths
while IFS="" read -r line; do
project_path=$(echo "$line" | sed -E 's"(git@|.+://)[^:/]+[:/](.+)/.+$"\2"')
repo_name=$(echo "$line" | sed -E -e 's|.+/(.+)$|\1|' -e 's|(.+)(.git)$|\1|')
echo "* '$line'"
echo " * '$project_path'"
echo " * '$repo_name'"
echo
done < ./example_urls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment