I have a text file that contains following
https://git.centos.org/git/rpms/abc.git
https://git.centos.org/git/rpms/abc.git/
https://git.centos.org/git/rpms/abc
When I run the following command,
reponame=$(echo $url | awk -F/ '{print $NF}' | sed -e 's/.git\/$//' | sed -e 's/.git//')
echo $reponame
I am supposed to get
abc
It fails for the lines ending in .git/
but it works for the other 2 cases.
abc
from all three lines?/
-separated field? I.e., will the string to parse always be something like1://2/3/4/xxx.git
or could it also be something like1://2/3/4/5/xxx.git
or1://2/3/xxx.git
?