I have the following command which allows me to get a list like the one below:
git ls-remote https://github.com/CodeEditApp/CodeEdit --h --sort origin "refs/heads/*"
...
45955931b326913390596b1970ebeb928ccc741e refs/heads/add-docs-video
4d872980b6a606b9d40c9c3afa5987bbac701fc2 refs/heads/animation-test
c3969f86ea8e332c5b7e63ea8d246d5e7917d475 refs/heads/apple
....
the result I would like to get in the end would be just the branch names:
...
add-docs-video
animation-test
apple
....
CodePudding user response:
You could use awk and grab the last field using /
as a separator and then print the rest of the line from the 3rd field using the substring function like so:
yourcommand | awk -F/ '{print substr($0, index($0,$3))}'
CodePudding user response:
Suggesting awk
script.
Setting awk
field separator /
and printing the last field.
git ls-remote https://github.com/CodeEditApp/CodeEdit --h --sort origin "refs/heads/*" | awk -F"/" '{print $NF}'