生活随笔
收集整理的這篇文章主要介紹了
(批量)备份github仓库到本地
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
shell腳本backup.sh#!/bin/bash
# tool-script: backup repositories from github
if [[ $# -eq 0 ]] || [[ $1 = "-h" ]];thenecho -e "\033[31m--------------------------------------------------------\033[0m"echo "Usage1: $0 URL"echo " e.g: $0 https://github.com/cherrishccl?tab=repositories"echo ""echo "Usage2: $0 Username Page"echo " e.g: $0 cherrishccl 1"echo -e "\033[31m--------------------------------------------------------\033[0m"exit 1;
fiurl=""
username=""
if [ $# == 1 ];thenurl="https://github.com/cherrishccl?tab=repositories"username=${url%\?*}username=${username##*/}
elseusername=$1url="https://github.com/${username}?page=${2}&tab=repositories"
fipatten1="a href=\"/"${username}"/"r_path=`curl "${url}" | grep "${patten1}"`# get repositories url pathpath_head="https://github.com/"for p in ${r_path}doif [[ $p =~ "href" ]];thenp=${p#*/}p=${p%\"*}p=${path_head}${p}echo -e "\033[33m ====== Download ====================\033[0m"echo -e "\033[32m $p \033[0m"git clone ${p}echo -e "\033[33m ====== $p has been Finished =================\033[0m"fidone
?執行腳本:bash backup.sh?https://github.com/cherrishccl?tab=repositories
轉載于:https://my.oschina.net/u/574036/blog/1624045
總結
以上是生活随笔為你收集整理的(批量)备份github仓库到本地的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。