I want to get first 8 characters of latest git commit hash. To retrieve git HEAD hash, I use git rev-parse HEAD
. I've found here that I can get a substring using ${string:position:length}
. But I don't know how to combine them both (in a one-liner, if possible). My attempt
${"`git rev-parse HEAD`":0:8}
is wrong.