在bash中从GitHub url中提取存储库名称
发布时间:2020-12-15 18:37:22 所属栏目:安全 来源:网络整理
导读:给出任何 GitHub存储库url字符串,如: git://github.com/some-user/my-repo.git 要么 git@github.com:some-user/my-repo.git 要么 https://github.com/some-user/my-repo.git bash从以下任何字符串中提取存储库名称my-repo的最佳方法是什么?该解决方案必须
给出任何
GitHub存储库url字符串,如:
git://github.com/some-user/my-repo.git 要么 git@github.com:some-user/my-repo.git 要么 https://github.com/some-user/my-repo.git bash从以下任何字符串中提取存储库名称my-repo的最佳方法是什么?该解决方案必须适用于上面指定的所有类型的URL. 谢谢. $url=git://github.com/some-user/my-repo.git $basename=$(basename $url) $echo $basename my-repo.git $filename=${basename%.*} $echo $filename my-repo $extension=${basename##*.} $echo $extension git (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何在给定的时间间隔内运行Unix命令?
- 输入adb shell 时 提示error: more than one device and em
- 在使用bash重定向时,我怎么能看到未来?
- Angular 6 Library使用bootstrap
- scala – 如何转换foldLeft:Double表达式使用Option [Doub
- angularjs – 在嵌套ng-repeat中传递2 $ index值
- 有没有办法使Scala REPL不能停止与CTRL-C
- bootstrap中的表单
- angular – 如何使用swiper库在Ionic2中创建幻灯片/轮播
- AngularJs Filter详解2--自定义过滤器